mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 20:45:33 +00:00
Implement text replacement for journal topic responses (Fixes #1429)
This commit is contained in:
parent
3bf599248e
commit
1ed3f092c1
8 changed files with 37 additions and 23 deletions
|
@ -59,7 +59,7 @@ namespace MWBase
|
|||
virtual int getJournalIndex (const std::string& id) const = 0;
|
||||
///< Get the journal index.
|
||||
|
||||
virtual void addTopic (const std::string& topicId, const std::string& infoId, const std::string& actorName) = 0;
|
||||
virtual void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) = 0;
|
||||
|
||||
virtual TEntryIter begin() const = 0;
|
||||
///< Iterator pointing to the begin of the main journal.
|
||||
|
|
|
@ -294,7 +294,7 @@ namespace MWDialogue
|
|||
{
|
||||
if (iter->mId == info->mId)
|
||||
{
|
||||
MWBase::Environment::get().getJournal()->addTopic (topic, info->mId, mActor.getClass().getName(mActor));
|
||||
MWBase::Environment::get().getJournal()->addTopic (topic, info->mId, mActor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ namespace MWDialogue
|
|||
{
|
||||
if (iter->mId == info->mId)
|
||||
{
|
||||
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId, mActor.getClass().getName(mActor));
|
||||
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId, mActor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,21 @@
|
|||
|
||||
#include <components/esm/journalentry.hpp>
|
||||
|
||||
#include <components/interpreter/defines.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "../mwscript/interpretercontext.hpp"
|
||||
|
||||
|
||||
namespace MWDialogue
|
||||
{
|
||||
Entry::Entry() {}
|
||||
|
||||
Entry::Entry (const std::string& topic, const std::string& infoId)
|
||||
Entry::Entry (const std::string& topic, const std::string& infoId, const MWWorld::Ptr& actor)
|
||||
: mInfoId (infoId)
|
||||
{
|
||||
const ESM::Dialogue *dialogue =
|
||||
|
@ -24,8 +29,17 @@ namespace MWDialogue
|
|||
iter!=dialogue->mInfo.end(); ++iter)
|
||||
if (iter->mId == mInfoId)
|
||||
{
|
||||
/// \todo text replacement
|
||||
mText = iter->mResponse;
|
||||
if (actor.isEmpty())
|
||||
{
|
||||
MWScript::InterpreterContext interpreterContext(NULL,MWWorld::Ptr());
|
||||
mText = Interpreter::fixDefinesDialog(iter->mResponse, interpreterContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
MWScript::InterpreterContext interpreterContext(&actor.getRefData().getLocals(),actor);
|
||||
mText = Interpreter::fixDefinesDialog(iter->mResponse, interpreterContext);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,8 +63,8 @@ namespace MWDialogue
|
|||
|
||||
JournalEntry::JournalEntry() {}
|
||||
|
||||
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId)
|
||||
: Entry (topic, infoId), mTopic (topic)
|
||||
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId, const MWWorld::Ptr& actor)
|
||||
: Entry (topic, infoId, actor), mTopic (topic)
|
||||
{}
|
||||
|
||||
JournalEntry::JournalEntry (const ESM::JournalEntry& record)
|
||||
|
@ -65,7 +79,7 @@ namespace MWDialogue
|
|||
|
||||
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index)
|
||||
{
|
||||
return JournalEntry (topic, idFromIndex (topic, index));
|
||||
return JournalEntry (topic, idFromIndex (topic, index), MWWorld::Ptr());
|
||||
}
|
||||
|
||||
std::string JournalEntry::idFromIndex (const std::string& topic, int index)
|
||||
|
@ -90,7 +104,7 @@ namespace MWDialogue
|
|||
|
||||
StampedJournalEntry::StampedJournalEntry (const std::string& topic, const std::string& infoId,
|
||||
int day, int month, int dayOfMonth)
|
||||
: JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth)
|
||||
: JournalEntry (topic, infoId, MWWorld::Ptr()), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth)
|
||||
{}
|
||||
|
||||
StampedJournalEntry::StampedJournalEntry (const ESM::JournalEntry& record)
|
||||
|
|
|
@ -8,6 +8,11 @@ namespace ESM
|
|||
struct JournalEntry;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
}
|
||||
|
||||
namespace MWDialogue
|
||||
{
|
||||
/// \brief Basic quest/dialogue/topic entry
|
||||
|
@ -19,7 +24,8 @@ namespace MWDialogue
|
|||
|
||||
Entry();
|
||||
|
||||
Entry (const std::string& topic, const std::string& infoId);
|
||||
/// actor is optional
|
||||
Entry (const std::string& topic, const std::string& infoId, const MWWorld::Ptr& actor);
|
||||
|
||||
Entry (const ESM::JournalEntry& record);
|
||||
|
||||
|
@ -37,7 +43,7 @@ namespace MWDialogue
|
|||
|
||||
JournalEntry();
|
||||
|
||||
JournalEntry (const std::string& topic, const std::string& infoId);
|
||||
JournalEntry (const std::string& topic, const std::string& infoId, const MWWorld::Ptr& actor);
|
||||
|
||||
JournalEntry (const ESM::JournalEntry& record);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <components/esm/journalentry.hpp>
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -103,12 +104,12 @@ namespace MWDialogue
|
|||
quest.setIndex (index);
|
||||
}
|
||||
|
||||
void Journal::addTopic (const std::string& topicId, const std::string& infoId, const std::string& actorName)
|
||||
void Journal::addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor)
|
||||
{
|
||||
Topic& topic = getTopic (topicId);
|
||||
|
||||
JournalEntry entry(topicId, infoId);
|
||||
entry.mActorName = actorName;
|
||||
JournalEntry entry(topicId, infoId, actor);
|
||||
entry.mActorName = actor.getClass().getName(actor);
|
||||
topic.addEntry (entry);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace MWDialogue
|
|||
virtual int getJournalIndex (const std::string& id) const;
|
||||
///< Get the journal index.
|
||||
|
||||
virtual void addTopic (const std::string& topicId, const std::string& infoId, const std::string& actorName);
|
||||
virtual void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor);
|
||||
|
||||
virtual TEntryIter begin() const;
|
||||
///< Iterator pointing to the begin of the main journal.
|
||||
|
|
|
@ -58,9 +58,4 @@ namespace MWDialogue
|
|||
{
|
||||
return mEntries.end();
|
||||
}
|
||||
|
||||
JournalEntry Topic::getEntry (const std::string& infoId) const
|
||||
{
|
||||
return JournalEntry (mTopic, infoId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,6 @@ namespace MWDialogue
|
|||
|
||||
TEntryIter end() const;
|
||||
///< Iterator pointing past the end of the journal for this topic.
|
||||
|
||||
JournalEntry getEntry (const std::string& infoId) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue