From d00d40cc3f567d008f980c83aa447718f08ed8d9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 9 Aug 2012 12:56:03 +0200 Subject: [PATCH] Issue #107: Journal is accessed only through the interface class from now on --- apps/openmw/CMakeLists.txt | 4 +- apps/openmw/engine.cpp | 2 +- apps/openmw/mwbase/environment.cpp | 7 +- apps/openmw/mwbase/environment.hpp | 12 +-- apps/openmw/mwbase/journal.hpp | 76 +++++++++++++++++++ apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 3 +- .../{journal.cpp => journalimp.cpp} | 2 +- .../{journal.hpp => journalimp.hpp} | 37 +++------ apps/openmw/mwgui/journalwindow.cpp | 5 +- apps/openmw/mwscript/dialogueextensions.cpp | 3 +- 10 files changed, 104 insertions(+), 47 deletions(-) create mode 100644 apps/openmw/mwbase/journal.hpp rename apps/openmw/mwdialogue/{journal.cpp => journalimp.cpp} (98%) rename apps/openmw/mwdialogue/{journal.hpp => journalimp.hpp} (52%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index b9da636cf..1dffc426d 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -32,7 +32,7 @@ add_openmw_dir (mwgui ) add_openmw_dir (mwdialogue - dialoguemanagerimp journal journalentry quest topic + dialoguemanagerimp journalimp journalentry quest topic ) add_openmw_dir (mwscript @@ -64,7 +64,7 @@ add_openmw_dir (mwmechanics ) add_openmw_dir (mwbase - environment world scriptmanager dialoguemanager + environment world scriptmanager dialoguemanager journal ) # Main executable diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index d97d40580..5659b1c37 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -30,7 +30,7 @@ #include "mwclass/classes.hpp" #include "mwdialogue/dialoguemanagerimp.hpp" -#include "mwdialogue/journal.hpp" +#include "mwdialogue/journalimp.hpp" #include "mwmechanics/mechanicsmanager.hpp" diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index c0fc56f97..25488af6c 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -7,13 +7,12 @@ #include "../mwsound/soundmanager.hpp" -#include "../mwdialogue/journal.hpp" - #include "../mwmechanics/mechanicsmanager.hpp" #include "world.hpp" #include "scriptmanager.hpp" #include "dialoguemanager.hpp" +#include "journal.hpp" MWBase::Environment *MWBase::Environment::sThis = 0; @@ -61,7 +60,7 @@ void MWBase::Environment::setDialogueManager (DialogueManager *dialogueManager) mDialogueManager = dialogueManager; } -void MWBase::Environment::setJournal (MWDialogue::Journal *journal) +void MWBase::Environment::setJournal (Journal *journal) { mJournal = journal; } @@ -112,7 +111,7 @@ MWBase::DialogueManager *MWBase::Environment::getDialogueManager() const return mDialogueManager; } -MWDialogue::Journal *MWBase::Environment::getJournal() const +MWBase::Journal *MWBase::Environment::getJournal() const { assert (mJournal); return mJournal; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 72d92f00f..160a63b0b 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -16,11 +16,6 @@ namespace MWMechanics class MechanicsManager; } -namespace MWDialogue -{ - class Journal; -} - namespace MWInput { struct MWInputManager; @@ -31,6 +26,7 @@ namespace MWBase class World; class ScriptManager; class DialogueManager; + class Journal; /// \brief Central hub for mw-subsystems /// @@ -48,7 +44,7 @@ namespace MWBase MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; DialogueManager *mDialogueManager; - MWDialogue::Journal *mJournal; + Journal *mJournal; MWInput::MWInputManager *mInputManager; float mFrameDuration; @@ -76,7 +72,7 @@ namespace MWBase void setDialogueManager (DialogueManager *dialogueManager); - void setJournal (MWDialogue::Journal *journal); + void setJournal (Journal *journal); void setInputManager (MWInput::MWInputManager *inputManager); @@ -95,7 +91,7 @@ namespace MWBase DialogueManager *getDialogueManager() const; - MWDialogue::Journal *getJournal() const; + Journal *getJournal() const; MWInput::MWInputManager *getInputManager() const; diff --git a/apps/openmw/mwbase/journal.hpp b/apps/openmw/mwbase/journal.hpp new file mode 100644 index 000000000..99f6996cf --- /dev/null +++ b/apps/openmw/mwbase/journal.hpp @@ -0,0 +1,76 @@ +#ifndef GAME_MWBASE_JOURNAL_H +#define GAME_MWBASE_JOURNAL_H + +#include +#include +#include + +namespace MWDialogue +{ + class Quest; + class Topic; + struct StampedJournalEntry; +} + +namespace MWBase +{ + /// \brief Interface for the player's journal (implemented in MWDialogue) + class Journal + { + Journal (const Journal&); + ///< not implemented + + Journal& operator= (const Journal&); + ///< not implemented + + public: + + typedef std::deque TEntryContainer; + typedef TEntryContainer::const_iterator TEntryIter; + typedef std::map TQuestContainer; // topc, quest + typedef TQuestContainer::const_iterator TQuestIter; + typedef std::map TTopicContainer; // topic-id, topic-content + typedef TTopicContainer::const_iterator TTopicIter; + + public: + + Journal() {} + + virtual ~Journal() {} + + virtual void addEntry (const std::string& id, int index) = 0; + ///< Add a journal entry. + + virtual void setJournalIndex (const std::string& id, int index) = 0; + ///< Set the journal index without adding an entry. + + virtual int getJournalIndex (const std::string& id) const = 0; + ///< Get the journal index. + + virtual void addTopic (const std::string& topicId, const std::string& infoId) = 0; + + virtual TEntryIter begin() const = 0; + ///< Iterator pointing to the begin of the main journal. + /// + /// \note Iterators to main journal entries will never become invalid. + + virtual TEntryIter end() const = 0; + ///< Iterator pointing past the end of the main journal. + + virtual TQuestIter questBegin() const = 0; + ///< Iterator pointing to the first quest (sorted by topic ID) + + virtual TQuestIter questEnd() const = 0; + ///< Iterator pointing past the last quest. + + virtual TTopicIter topicBegin() const = 0; + ///< Iterator pointing to the first topic (sorted by topic ID) + /// + /// \note The topic ID is identical with the user-visible topic string. + + virtual TTopicIter topicEnd() const = 0; + ///< Iterator pointing past the last topic. + }; +} + +#endif diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 129e78d0f..644da49e2 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -12,6 +12,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/scriptmanager.hpp" +#include "../mwbase/journal.hpp" #include "../mwworld/class.hpp" #include "../mwworld/refdata.hpp" @@ -22,8 +23,6 @@ #include "../mwgui/dialogue.hpp" #include "../mwgui/window_manager.hpp" -#include "journal.hpp" - #include #include "../mwscript/extensions.hpp" diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journalimp.cpp similarity index 98% rename from apps/openmw/mwdialogue/journal.cpp rename to apps/openmw/mwdialogue/journalimp.cpp index ad10be3aa..052b92194 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journalimp.cpp @@ -1,5 +1,5 @@ -#include "journal.hpp" +#include "journalimp.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journalimp.hpp similarity index 52% rename from apps/openmw/mwdialogue/journal.hpp rename to apps/openmw/mwdialogue/journalimp.hpp index 62b9f4bed..5fafc265a 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journalimp.hpp @@ -1,9 +1,7 @@ #ifndef GAME_MMDIALOG_JOURNAL_H #define GAME_MWDIALOG_JOURNAL_H -#include -#include -#include +#include "../mwbase/journal.hpp" #include "journalentry.hpp" #include "quest.hpp" @@ -11,19 +9,8 @@ namespace MWDialogue { /// \brief The player's journal - class Journal + class Journal : public MWBase::Journal { - public: - - typedef std::deque TEntryContainer; - typedef TEntryContainer::const_iterator TEntryIter; - typedef std::map TQuestContainer; // topc, quest - typedef TQuestContainer::const_iterator TQuestIter; - typedef std::map TTopicContainer; // topic-id, topic-content - typedef TTopicContainer::const_iterator TTopicIter; - - private: - TEntryContainer mJournal; TQuestContainer mQuests; TTopicContainer mTopics; @@ -34,37 +21,37 @@ namespace MWDialogue Journal(); - void addEntry (const std::string& id, int index); + virtual void addEntry (const std::string& id, int index); ///< Add a journal entry. - void setJournalIndex (const std::string& id, int index); + virtual void setJournalIndex (const std::string& id, int index); ///< Set the journal index without adding an entry. - int getJournalIndex (const std::string& id) const; + virtual int getJournalIndex (const std::string& id) const; ///< Get the journal index. - void addTopic (const std::string& topicId, const std::string& infoId); + virtual void addTopic (const std::string& topicId, const std::string& infoId); - TEntryIter begin() const; + virtual TEntryIter begin() const; ///< Iterator pointing to the begin of the main journal. /// /// \note Iterators to main journal entries will never become invalid. - TEntryIter end() const; + virtual TEntryIter end() const; ///< Iterator pointing past the end of the main journal. - TQuestIter questBegin() const; + virtual TQuestIter questBegin() const; ///< Iterator pointing to the first quest (sorted by topic ID) - TQuestIter questEnd() const; + virtual TQuestIter questEnd() const; ///< Iterator pointing past the last quest. - TTopicIter topicBegin() const; + virtual TTopicIter topicBegin() const; ///< Iterator pointing to the first topic (sorted by topic ID) /// /// \note The topic ID is identical with the user-visible topic string. - TTopicIter topicEnd() const; + virtual TTopicIter topicEnd() const; ///< Iterator pointing past the last topic. }; } diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 8b50c9ef1..220cd96e7 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -2,11 +2,12 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" - -#include "../mwdialogue/journal.hpp" +#include "../mwbase/journal.hpp" #include "../mwsound/soundmanager.hpp" +#include "../mwdialogue/journalentry.hpp" + #include "window_manager.hpp" namespace diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 4eb129331..21c21acf0 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -9,8 +9,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/dialoguemanager.hpp" - -#include "../mwdialogue/journal.hpp" +#include "../mwbase/journal.hpp" #include "interpretercontext.hpp" #include "ref.hpp"