added journal entry struct

actorid
Marc Zinnschlag 14 years ago
parent e4a0702bb4
commit 5851e0a28c

@ -71,10 +71,12 @@ source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI})
set(GAMEDIALOGUE_HEADER
mwdialogue/dialoguemanager.hpp
mwdialogue/journal.hpp
mwdialogue/journalentry.hpp
)
set(GAMEDIALOGUE
mwdialogue/dialoguemanager.cpp
mwdialogue/journal.cpp
mwdialogue/journalentry.cpp
)
source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE})

@ -0,0 +1,27 @@
#include "journalentry.hpp"
#include <stdexcept>
#include <components/esm_store/store.hpp>
namespace MWDialogue
{
JournalEntry::JournalEntry() {}
JournalEntry::JournalEntry (int day, const std::string& topic, const std::string& infoId)
: mDay (day), mTopic (topic), mInfoId (infoId)
{}
std::string JournalEntry::getText (const ESMS::ESMStore& store) const
{
const ESM::Dialogue *dialogue = store.dialogs.find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
if (iter->id==mInfoId)
return iter->response;
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic);
}
}

@ -0,0 +1,29 @@
#ifndef GAME_MMDIALOGUE_JOURNALENTRY_H
#define GAME_MWDIALOGUE_JOURNALENTRY_H
#include <string>
namespace ESMS
{
struct ESMStore;
}
namespace MWDialogue
{
/// \brief a quest or dialogue entry with a timestamp
struct JournalEntry
{
int mDay;
std::string mTopic;
std::string mInfoId;
JournalEntry();
JournalEntry (int day, const std::string& topic, const std::string& infoId);
std::string getText (const ESMS::ESMStore& store) const;
};
}
#endif
Loading…
Cancel
Save