1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 17:45:34 +00:00

splitting JournalEntry into Entry and JournalEntry

This commit is contained in:
Marc Zinnschlag 2013-12-01 14:44:27 +01:00
parent 16e2d67b1f
commit b273f9e387
3 changed files with 32 additions and 19 deletions

View file

@ -10,13 +10,13 @@
namespace MWDialogue namespace MWDialogue
{ {
JournalEntry::JournalEntry() {} Entry::Entry() {}
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId) Entry::Entry (const std::string& topic, const std::string& infoId)
: mTopic (topic), mInfoId (infoId) : mInfoId (infoId)
{ {
const ESM::Dialogue *dialogue = const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic); MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
@ -27,14 +27,21 @@ namespace MWDialogue
return; return;
} }
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + topic);
} }
std::string JournalEntry::getText (const MWWorld::ESMStore& store) const std::string Entry::getText() const
{ {
return mText; return mText;
} }
JournalEntry::JournalEntry() {}
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId)
: Entry (topic, infoId), mTopic (topic)
{}
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));
@ -55,6 +62,7 @@ namespace MWDialogue
throw std::runtime_error ("unknown journal index for topic " + topic); throw std::runtime_error ("unknown journal index for topic " + topic);
} }
StampedJournalEntry::StampedJournalEntry() StampedJournalEntry::StampedJournalEntry()
: mDay (0), mMonth (0), mDayOfMonth (0) : mDay (0), mMonth (0), mDayOfMonth (0)
{} {}

View file

@ -3,26 +3,32 @@
#include <string> #include <string>
namespace MWWorld
{
struct ESMStore;
}
namespace MWDialogue namespace MWDialogue
{ {
/// \brief A quest or dialogue entry /// \brief Basic quest/dialogue/topic entry
struct JournalEntry struct Entry
{ {
std::string mTopic;
std::string mInfoId; std::string mInfoId;
std::string mText; std::string mText;
Entry();
Entry (const std::string& topic, const std::string& infoId);
std::string getText() const;
};
/// \brief A dialogue entry
///
/// Same as entry, but store TopicID
struct JournalEntry : public Entry
{
std::string mTopic;
JournalEntry(); JournalEntry();
JournalEntry (const std::string& topic, const std::string& infoId); JournalEntry (const std::string& topic, const std::string& infoId);
std::string getText (const MWWorld::ESMStore& store) const;
static JournalEntry makeFromQuest (const std::string& topic, int index); static JournalEntry makeFromQuest (const std::string& topic, int index);
static std::string idFromIndex (const std::string& topic, int index); static std::string idFromIndex (const std::string& topic, int index);

View file

@ -233,7 +233,7 @@ struct JournalViewModelImpl : JournalViewModel
std::string getText () const std::string getText () const
{ {
return itr->getText(MWBase::Environment::get().getWorld()->getStore()); return itr->getText();
} }
Utf8Span timestamp () const Utf8Span timestamp () const
@ -317,8 +317,7 @@ struct JournalViewModelImpl : JournalViewModel
std::string getText () const std::string getText () const
{ {
return mTopic.getEntry (*itr).getText(MWBase::Environment::get().getWorld()->getStore()); return mTopic.getEntry (*itr).getText();
} }
Utf8Span source () const Utf8Span source () const