mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 12:39:40 +00:00
splitted StampedJournalEntry class off from JournalEntry
This commit is contained in:
parent
f3fecdc627
commit
65e43c448a
4 changed files with 51 additions and 10 deletions
|
@ -12,7 +12,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
void Journal::addEntry (const std::string& id, int index)
|
void Journal::addEntry (const std::string& id, int index)
|
||||||
{
|
{
|
||||||
mJournal.push_back (JournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld));
|
mJournal.push_back (StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld));
|
||||||
std::cout << "journal: " << id << " at " << index << std::endl;
|
std::cout << "journal: " << id << " at " << index << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::deque<JournalEntry> TEntryContainer;
|
typedef std::deque<StampedJournalEntry> TEntryContainer;
|
||||||
typedef TEntryContainer::const_iterator TEntryIter;
|
typedef TEntryContainer::const_iterator TEntryIter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MWWorld::Environment& mEnvironment;
|
MWWorld::Environment& mEnvironment;
|
||||||
std::deque<JournalEntry> mJournal;
|
TEntryContainer mJournal;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
JournalEntry::JournalEntry() {}
|
JournalEntry::JournalEntry() {}
|
||||||
|
|
||||||
JournalEntry::JournalEntry (int day, const std::string& topic, const std::string& infoId)
|
JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId)
|
||||||
: mDay (day), mTopic (topic), mInfoId (infoId)
|
: mTopic (topic), mInfoId (infoId)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string JournalEntry::getText (const ESMS::ESMStore& store) const
|
std::string JournalEntry::getText (const ESMS::ESMStore& store) const
|
||||||
|
@ -29,6 +29,12 @@ namespace MWDialogue
|
||||||
|
|
||||||
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index,
|
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index,
|
||||||
const MWWorld::World& world)
|
const MWWorld::World& world)
|
||||||
|
{
|
||||||
|
return JournalEntry (topic, idFromIndex (topic, index, world));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string JournalEntry::idFromIndex (const std::string& topic, int index,
|
||||||
|
const MWWorld::World& world)
|
||||||
{
|
{
|
||||||
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic);
|
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic);
|
||||||
|
|
||||||
|
@ -36,10 +42,28 @@ namespace MWDialogue
|
||||||
iter!=dialogue->mInfo.end(); ++iter)
|
iter!=dialogue->mInfo.end(); ++iter)
|
||||||
if (iter->data.disposition==index) /// \todo cleanup info structure
|
if (iter->data.disposition==index) /// \todo cleanup info structure
|
||||||
{
|
{
|
||||||
int day = world.getGlobalVariable ("dayspassed").mLong;
|
iter->id;
|
||||||
return JournalEntry (day, topic, iter->id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw std::runtime_error ("unknown journal index for topic " + topic);
|
throw std::runtime_error ("unknown journal index for topic " + topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StampedJournalEntry::StampedJournalEntry()
|
||||||
|
: mDay (0), mMonth (0), mDayOfMonth (0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index,
|
||||||
|
const MWWorld::World& world)
|
||||||
|
{
|
||||||
|
int day = world.getGlobalVariable ("dayspassed").mLong;
|
||||||
|
int month = world.getGlobalVariable ("day").mLong;
|
||||||
|
int dayOfMonth = world.getGlobalVariable ("month").mLong;
|
||||||
|
|
||||||
|
return StampedJournalEntry (topic, idFromIndex (topic, index, world), day, month, dayOfMonth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,23 +15,40 @@ namespace MWWorld
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
/// \brief a quest or dialogue entry with a timestamp
|
/// \brief A quest or dialogue entry
|
||||||
struct JournalEntry
|
struct JournalEntry
|
||||||
{
|
{
|
||||||
int mDay;
|
|
||||||
std::string mTopic;
|
std::string mTopic;
|
||||||
std::string mInfoId;
|
std::string mInfoId;
|
||||||
|
|
||||||
JournalEntry();
|
JournalEntry();
|
||||||
|
|
||||||
JournalEntry (int day, const std::string& topic, const std::string& infoId);
|
JournalEntry (const std::string& topic, const std::string& infoId);
|
||||||
|
|
||||||
std::string getText (const ESMS::ESMStore& store) const;
|
std::string getText (const ESMS::ESMStore& store) const;
|
||||||
|
|
||||||
static JournalEntry makeFromQuest (const std::string& topic, int index,
|
static JournalEntry makeFromQuest (const std::string& topic, int index,
|
||||||
const MWWorld::World& world);
|
const MWWorld::World& world);
|
||||||
|
|
||||||
|
static std::string idFromIndex (const std::string& topic, int index,
|
||||||
|
const MWWorld::World& world);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \biref A quest entry with a timestamp.
|
||||||
|
struct StampedJournalEntry : public JournalEntry
|
||||||
|
{
|
||||||
|
int mDay;
|
||||||
|
int mMonth;
|
||||||
|
int mDayOfMonth;
|
||||||
|
|
||||||
|
StampedJournalEntry();
|
||||||
|
|
||||||
|
StampedJournalEntry (const std::string& topic, const std::string& infoId,
|
||||||
|
int day, int month, int dayOfMonth);
|
||||||
|
|
||||||
|
static StampedJournalEntry makeFromQuest (const std::string& topic, int index,
|
||||||
|
const MWWorld::World& world);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue