From 5851e0a28c6d9c24530a24f3bbb6cc87f683ee45 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Apr 2011 10:54:11 +0200 Subject: [PATCH] added journal entry struct --- apps/openmw/CMakeLists.txt | 2 ++ apps/openmw/mwdialogue/journalentry.cpp | 27 +++++++++++++++++++++++ apps/openmw/mwdialogue/journalentry.hpp | 29 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 apps/openmw/mwdialogue/journalentry.cpp create mode 100644 apps/openmw/mwdialogue/journalentry.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 3cb08b5f7..63add2fce 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -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}) diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp new file mode 100644 index 000000000..8e3aeb93b --- /dev/null +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -0,0 +1,27 @@ + +#include "journalentry.hpp" + +#include + +#include + +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::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); + } +} diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp new file mode 100644 index 000000000..8506b9dbc --- /dev/null +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -0,0 +1,29 @@ +#ifndef GAME_MMDIALOGUE_JOURNALENTRY_H +#define GAME_MWDIALOGUE_JOURNALENTRY_H + +#include + +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