mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:23:52 +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;
|
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, 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;
|
virtual TEntryIter begin() const = 0;
|
||||||
///< Iterator pointing to the begin of the main journal.
|
///< Iterator pointing to the begin of the main journal.
|
||||||
|
|
|
@ -294,7 +294,7 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
if (iter->mId == info->mId)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
if (iter->mId == info->mId)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,21 @@
|
||||||
|
|
||||||
#include <components/esm/journalentry.hpp>
|
#include <components/esm/journalentry.hpp>
|
||||||
|
|
||||||
|
#include <components/interpreter/defines.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
|
||||||
|
#include "../mwscript/interpretercontext.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
Entry::Entry() {}
|
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)
|
: mInfoId (infoId)
|
||||||
{
|
{
|
||||||
const ESM::Dialogue *dialogue =
|
const ESM::Dialogue *dialogue =
|
||||||
|
@ -24,8 +29,17 @@ namespace MWDialogue
|
||||||
iter!=dialogue->mInfo.end(); ++iter)
|
iter!=dialogue->mInfo.end(); ++iter)
|
||||||
if (iter->mId == mInfoId)
|
if (iter->mId == mInfoId)
|
||||||
{
|
{
|
||||||
/// \todo text replacement
|
if (actor.isEmpty())
|
||||||
mText = iter->mResponse;
|
{
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +63,8 @@ namespace MWDialogue
|
||||||
|
|
||||||
JournalEntry::JournalEntry() {}
|
JournalEntry::JournalEntry() {}
|
||||||
|
|
||||||
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId)
|
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId, const MWWorld::Ptr& actor)
|
||||||
: Entry (topic, infoId), mTopic (topic)
|
: Entry (topic, infoId, actor), mTopic (topic)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
JournalEntry::JournalEntry (const ESM::JournalEntry& record)
|
JournalEntry::JournalEntry (const ESM::JournalEntry& record)
|
||||||
|
@ -65,7 +79,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index)
|
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)
|
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,
|
StampedJournalEntry::StampedJournalEntry (const std::string& topic, const std::string& infoId,
|
||||||
int day, int month, int dayOfMonth)
|
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)
|
StampedJournalEntry::StampedJournalEntry (const ESM::JournalEntry& record)
|
||||||
|
|
|
@ -8,6 +8,11 @@ namespace ESM
|
||||||
struct JournalEntry;
|
struct JournalEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class Ptr;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
/// \brief Basic quest/dialogue/topic entry
|
/// \brief Basic quest/dialogue/topic entry
|
||||||
|
@ -19,7 +24,8 @@ namespace MWDialogue
|
||||||
|
|
||||||
Entry();
|
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);
|
Entry (const ESM::JournalEntry& record);
|
||||||
|
|
||||||
|
@ -37,7 +43,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
JournalEntry();
|
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);
|
JournalEntry (const ESM::JournalEntry& record);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <components/esm/journalentry.hpp>
|
#include <components/esm/journalentry.hpp>
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -103,12 +104,12 @@ namespace MWDialogue
|
||||||
quest.setIndex (index);
|
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);
|
Topic& topic = getTopic (topicId);
|
||||||
|
|
||||||
JournalEntry entry(topicId, infoId);
|
JournalEntry entry(topicId, infoId, actor);
|
||||||
entry.mActorName = actorName;
|
entry.mActorName = actor.getClass().getName(actor);
|
||||||
topic.addEntry (entry);
|
topic.addEntry (entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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, const std::string& actorName);
|
virtual void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
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.
|
||||||
|
|
|
@ -58,9 +58,4 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
return mEntries.end();
|
return mEntries.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
JournalEntry Topic::getEntry (const std::string& infoId) const
|
|
||||||
{
|
|
||||||
return JournalEntry (mTopic, infoId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,6 @@ namespace MWDialogue
|
||||||
|
|
||||||
TEntryIter end() const;
|
TEntryIter end() const;
|
||||||
///< Iterator pointing past the end of the journal for this topic.
|
///< Iterator pointing past the end of the journal for this topic.
|
||||||
|
|
||||||
JournalEntry getEntry (const std::string& infoId) const;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue