Feature #764: Store the actor that gave the dialog response

actorid
scrawl 11 years ago
parent a988a0d6dc
commit f89b3cac02

@ -54,7 +54,7 @@ namespace MWBase
virtual int getJournalIndex (const std::string& id) const = 0; virtual int getJournalIndex (const std::string& id) const = 0;
///< Get the journal index. ///< Get the journal index.
virtual void addTopic (const std::string& topicId, const std::string& infoId) = 0; virtual void addTopic (const std::string& topicId, const std::string& infoId, const std::string& actorName) = 0;
virtual TEntryIter begin() const = 0; virtual TEntryIter begin() const = 0;
///< Iterator pointing to the begin of the main journal. ///< Iterator pointing to the begin of the main journal.

@ -286,7 +286,7 @@ namespace MWDialogue
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), title); win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), title);
MWBase::Environment::get().getJournal()->addTopic (topic, info->mId); MWBase::Environment::get().getJournal()->addTopic (topic, info->mId, mActor.getClass().getName(mActor));
executeScript (info->mResultScript); executeScript (info->mResultScript);
@ -451,7 +451,7 @@ namespace MWDialogue
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse (Interpreter::fixDefinesDialog(text, interpreterContext)); MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse (Interpreter::fixDefinesDialog(text, interpreterContext));
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId); MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId, mActor.getClass().getName(mActor));
executeScript (info->mResultScript); executeScript (info->mResultScript);
} }
} }

@ -32,7 +32,7 @@ namespace MWDialogue
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + topic); throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + topic);
} }
Entry::Entry (const ESM::JournalEntry& record) : mInfoId (record.mInfo), mText (record.mText) {} Entry::Entry (const ESM::JournalEntry& record) : mInfoId (record.mInfo), mText (record.mText), mActorName(record.mActorName) {}
std::string Entry::getText() const std::string Entry::getText() const
{ {
@ -43,6 +43,7 @@ namespace MWDialogue
{ {
entry.mInfo = mInfoId; entry.mInfo = mInfoId;
entry.mText = mText; entry.mText = mText;
entry.mActorName = mActorName;
} }

@ -15,6 +15,7 @@ namespace MWDialogue
{ {
std::string mInfoId; std::string mInfoId;
std::string mText; std::string mText;
std::string mActorName; // optional
Entry(); Entry();

@ -103,11 +103,13 @@ namespace MWDialogue
quest.setIndex (index); quest.setIndex (index);
} }
void Journal::addTopic (const std::string& topicId, const std::string& infoId) void Journal::addTopic (const std::string& topicId, const std::string& infoId, const std::string& actorName)
{ {
Topic& topic = getTopic (topicId); Topic& topic = getTopic (topicId);
topic.addEntry (JournalEntry (topicId, infoId)); JournalEntry entry(topicId, infoId);
entry.mActorName = actorName;
topic.addEntry (entry);
} }
int Journal::getJournalIndex (const std::string& id) const int Journal::getJournalIndex (const std::string& id) const

@ -38,7 +38,7 @@ namespace MWDialogue
virtual int getJournalIndex (const std::string& id) const; virtual int getJournalIndex (const std::string& id) const;
///< Get the journal index. ///< Get the journal index.
virtual void addTopic (const std::string& topicId, const std::string& infoId); virtual void addTopic (const std::string& topicId, const std::string& infoId, const std::string& actorName);
virtual TEntryIter begin() const; virtual TEntryIter begin() const;
///< Iterator pointing to the begin of the main journal. ///< Iterator pointing to the begin of the main journal.

@ -311,8 +311,6 @@ struct JournalViewModelImpl : JournalViewModel
{ {
MWDialogue::Topic const & mTopic; MWDialogue::Topic const & mTopic;
mutable std::string source_buffer;
TopicEntryImpl (JournalViewModelImpl const * model, MWDialogue::Topic const & topic, iterator_t itr) : TopicEntryImpl (JournalViewModelImpl const * model, MWDialogue::Topic const & topic, iterator_t itr) :
BaseEntry (model, itr), mTopic (topic) BaseEntry (model, itr), mTopic (topic)
{} {}
@ -324,9 +322,7 @@ struct JournalViewModelImpl : JournalViewModel
Utf8Span source () const Utf8Span source () const
{ {
if (source_buffer.empty ()) return toUtf8Span (itr->mActorName);
source_buffer = "someone";
return toUtf8Span (source_buffer);
} }
}; };

@ -17,6 +17,8 @@ void ESM::JournalEntry::load (ESMReader &esm)
esm.getHNT (mMonth, "JEMO"); esm.getHNT (mMonth, "JEMO");
esm.getHNT (mDayOfMonth, "JEDM"); esm.getHNT (mDayOfMonth, "JEDM");
} }
else if (mType==Type_Topic)
mActorName = esm.getHNOString("ACT_");
} }
void ESM::JournalEntry::save (ESMWriter &esm) const void ESM::JournalEntry::save (ESMWriter &esm) const
@ -32,4 +34,6 @@ void ESM::JournalEntry::save (ESMWriter &esm) const
esm.writeHNT ("JEMO", mMonth); esm.writeHNT ("JEMO", mMonth);
esm.writeHNT ("JEDM", mDayOfMonth); esm.writeHNT ("JEDM", mDayOfMonth);
} }
else if (mType==Type_Topic)
esm.writeHNString ("ACT_", mActorName);
} }

@ -23,6 +23,7 @@ namespace ESM
std::string mTopic; std::string mTopic;
std::string mInfo; std::string mInfo;
std::string mText; std::string mText;
std::string mActorName; // Could also be Actor ID to allow switching of localisation, but since mText is plaintext anyway...
int mDay; // time stamp int mDay; // time stamp
int mMonth; int mMonth;
int mDayOfMonth; int mDayOfMonth;

Loading…
Cancel
Save