2011-04-26 18:39:59 +00:00
|
|
|
|
|
|
|
#include "topic.hpp"
|
|
|
|
|
2013-11-30 11:41:18 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2012-10-01 15:17:04 +00:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2011-04-26 18:39:59 +00:00
|
|
|
|
|
|
|
namespace MWDialogue
|
|
|
|
{
|
|
|
|
Topic::Topic()
|
|
|
|
{}
|
|
|
|
|
|
|
|
Topic::Topic (const std::string& topic)
|
2013-11-30 11:41:18 +00:00
|
|
|
: mTopic (topic), mName (
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic)->mId)
|
2011-04-26 18:39:59 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
Topic::~Topic()
|
|
|
|
{}
|
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
void Topic::addEntry (const JournalEntry& entry)
|
2011-04-26 18:39:59 +00:00
|
|
|
{
|
|
|
|
if (entry.mTopic!=mTopic)
|
|
|
|
throw std::runtime_error ("topic does not match: " + mTopic);
|
|
|
|
|
2014-01-25 22:07:52 +00:00
|
|
|
// bail out if we already have heard this
|
|
|
|
for (Topic::TEntryIter it = mEntries.begin(); it != mEntries.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it->mInfoId == entry.mInfoId)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-01 13:50:25 +00:00
|
|
|
mEntries.push_back (entry); // we want slicing here
|
2011-04-26 18:39:59 +00:00
|
|
|
}
|
|
|
|
|
2013-12-03 13:28:46 +00:00
|
|
|
void Topic::insertEntry (const ESM::JournalEntry& entry)
|
|
|
|
{
|
|
|
|
mEntries.push_back (entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Topic::getTopic() const
|
|
|
|
{
|
|
|
|
return mTopic;
|
|
|
|
}
|
|
|
|
|
2013-11-30 11:41:18 +00:00
|
|
|
std::string Topic::getName() const
|
|
|
|
{
|
|
|
|
return mName;
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:21:41 +00:00
|
|
|
Topic::TEntryIter Topic::begin() const
|
2011-04-26 18:39:59 +00:00
|
|
|
{
|
|
|
|
return mEntries.begin();
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:21:41 +00:00
|
|
|
Topic::TEntryIter Topic::end() const
|
2011-04-26 18:39:59 +00:00
|
|
|
{
|
|
|
|
return mEntries.end();
|
|
|
|
}
|
2014-06-10 14:36:22 +00:00
|
|
|
|
|
|
|
void Topic::removeLastAddedResponse (const std::string& actorName)
|
|
|
|
{
|
|
|
|
for (std::vector<MWDialogue::Entry>::reverse_iterator it = mEntries.rbegin();
|
|
|
|
it != mEntries.rend(); ++it)
|
|
|
|
{
|
|
|
|
if (it->mActorName == actorName)
|
|
|
|
{
|
|
|
|
mEntries.erase( (++it).base() ); // erase doesn't take a reverse_iterator
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-26 18:39:59 +00:00
|
|
|
}
|