Issue #107: Journal is accessed only through the interface class from now on

This commit is contained in:
Marc Zinnschlag 2012-08-09 12:56:03 +02:00
parent a84145a087
commit d00d40cc3f
10 changed files with 104 additions and 47 deletions

View file

@ -32,7 +32,7 @@ add_openmw_dir (mwgui
) )
add_openmw_dir (mwdialogue add_openmw_dir (mwdialogue
dialoguemanagerimp journal journalentry quest topic dialoguemanagerimp journalimp journalentry quest topic
) )
add_openmw_dir (mwscript add_openmw_dir (mwscript
@ -64,7 +64,7 @@ add_openmw_dir (mwmechanics
) )
add_openmw_dir (mwbase add_openmw_dir (mwbase
environment world scriptmanager dialoguemanager environment world scriptmanager dialoguemanager journal
) )
# Main executable # Main executable

View file

@ -30,7 +30,7 @@
#include "mwclass/classes.hpp" #include "mwclass/classes.hpp"
#include "mwdialogue/dialoguemanagerimp.hpp" #include "mwdialogue/dialoguemanagerimp.hpp"
#include "mwdialogue/journal.hpp" #include "mwdialogue/journalimp.hpp"
#include "mwmechanics/mechanicsmanager.hpp" #include "mwmechanics/mechanicsmanager.hpp"

View file

@ -7,13 +7,12 @@
#include "../mwsound/soundmanager.hpp" #include "../mwsound/soundmanager.hpp"
#include "../mwdialogue/journal.hpp"
#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/mechanicsmanager.hpp"
#include "world.hpp" #include "world.hpp"
#include "scriptmanager.hpp" #include "scriptmanager.hpp"
#include "dialoguemanager.hpp" #include "dialoguemanager.hpp"
#include "journal.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment *MWBase::Environment::sThis = 0;
@ -61,7 +60,7 @@ void MWBase::Environment::setDialogueManager (DialogueManager *dialogueManager)
mDialogueManager = dialogueManager; mDialogueManager = dialogueManager;
} }
void MWBase::Environment::setJournal (MWDialogue::Journal *journal) void MWBase::Environment::setJournal (Journal *journal)
{ {
mJournal = journal; mJournal = journal;
} }
@ -112,7 +111,7 @@ MWBase::DialogueManager *MWBase::Environment::getDialogueManager() const
return mDialogueManager; return mDialogueManager;
} }
MWDialogue::Journal *MWBase::Environment::getJournal() const MWBase::Journal *MWBase::Environment::getJournal() const
{ {
assert (mJournal); assert (mJournal);
return mJournal; return mJournal;

View file

@ -16,11 +16,6 @@ namespace MWMechanics
class MechanicsManager; class MechanicsManager;
} }
namespace MWDialogue
{
class Journal;
}
namespace MWInput namespace MWInput
{ {
struct MWInputManager; struct MWInputManager;
@ -31,6 +26,7 @@ namespace MWBase
class World; class World;
class ScriptManager; class ScriptManager;
class DialogueManager; class DialogueManager;
class Journal;
/// \brief Central hub for mw-subsystems /// \brief Central hub for mw-subsystems
/// ///
@ -48,7 +44,7 @@ namespace MWBase
MWGui::WindowManager *mWindowManager; MWGui::WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager; MWMechanics::MechanicsManager *mMechanicsManager;
DialogueManager *mDialogueManager; DialogueManager *mDialogueManager;
MWDialogue::Journal *mJournal; Journal *mJournal;
MWInput::MWInputManager *mInputManager; MWInput::MWInputManager *mInputManager;
float mFrameDuration; float mFrameDuration;
@ -76,7 +72,7 @@ namespace MWBase
void setDialogueManager (DialogueManager *dialogueManager); void setDialogueManager (DialogueManager *dialogueManager);
void setJournal (MWDialogue::Journal *journal); void setJournal (Journal *journal);
void setInputManager (MWInput::MWInputManager *inputManager); void setInputManager (MWInput::MWInputManager *inputManager);
@ -95,7 +91,7 @@ namespace MWBase
DialogueManager *getDialogueManager() const; DialogueManager *getDialogueManager() const;
MWDialogue::Journal *getJournal() const; Journal *getJournal() const;
MWInput::MWInputManager *getInputManager() const; MWInput::MWInputManager *getInputManager() const;

View file

@ -0,0 +1,76 @@
#ifndef GAME_MWBASE_JOURNAL_H
#define GAME_MWBASE_JOURNAL_H
#include <string>
#include <deque>
#include <map>
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<MWDialogue::StampedJournalEntry> TEntryContainer;
typedef TEntryContainer::const_iterator TEntryIter;
typedef std::map<std::string, MWDialogue::Quest> TQuestContainer; // topc, quest
typedef TQuestContainer::const_iterator TQuestIter;
typedef std::map<std::string, MWDialogue::Topic> 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

View file

@ -12,6 +12,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/scriptmanager.hpp" #include "../mwbase/scriptmanager.hpp"
#include "../mwbase/journal.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
@ -22,8 +23,6 @@
#include "../mwgui/dialogue.hpp" #include "../mwgui/dialogue.hpp"
#include "../mwgui/window_manager.hpp" #include "../mwgui/window_manager.hpp"
#include "journal.hpp"
#include <iostream> #include <iostream>
#include "../mwscript/extensions.hpp" #include "../mwscript/extensions.hpp"

View file

@ -1,5 +1,5 @@
#include "journal.hpp" #include "journalimp.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"

View file

@ -1,9 +1,7 @@
#ifndef GAME_MMDIALOG_JOURNAL_H #ifndef GAME_MMDIALOG_JOURNAL_H
#define GAME_MWDIALOG_JOURNAL_H #define GAME_MWDIALOG_JOURNAL_H
#include <string> #include "../mwbase/journal.hpp"
#include <deque>
#include <map>
#include "journalentry.hpp" #include "journalentry.hpp"
#include "quest.hpp" #include "quest.hpp"
@ -11,19 +9,8 @@
namespace MWDialogue namespace MWDialogue
{ {
/// \brief The player's journal /// \brief The player's journal
class Journal class Journal : public MWBase::Journal
{ {
public:
typedef std::deque<StampedJournalEntry> TEntryContainer;
typedef TEntryContainer::const_iterator TEntryIter;
typedef std::map<std::string, Quest> TQuestContainer; // topc, quest
typedef TQuestContainer::const_iterator TQuestIter;
typedef std::map<std::string, Topic> TTopicContainer; // topic-id, topic-content
typedef TTopicContainer::const_iterator TTopicIter;
private:
TEntryContainer mJournal; TEntryContainer mJournal;
TQuestContainer mQuests; TQuestContainer mQuests;
TTopicContainer mTopics; TTopicContainer mTopics;
@ -34,37 +21,37 @@ namespace MWDialogue
Journal(); Journal();
void addEntry (const std::string& id, int index); virtual void addEntry (const std::string& id, int index);
///< Add a journal entry. ///< 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. ///< 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. ///< 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. ///< Iterator pointing to the begin of the main journal.
/// ///
/// \note Iterators to main journal entries will never become invalid. /// \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. ///< 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) ///< Iterator pointing to the first quest (sorted by topic ID)
TQuestIter questEnd() const; virtual TQuestIter questEnd() const;
///< Iterator pointing past the last quest. ///< Iterator pointing past the last quest.
TTopicIter topicBegin() const; virtual TTopicIter topicBegin() const;
///< Iterator pointing to the first topic (sorted by topic ID) ///< Iterator pointing to the first topic (sorted by topic ID)
/// ///
/// \note The topic ID is identical with the user-visible topic string. /// \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. ///< Iterator pointing past the last topic.
}; };
} }

View file

@ -2,11 +2,12 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/journal.hpp"
#include "../mwdialogue/journal.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwsound/soundmanager.hpp"
#include "../mwdialogue/journalentry.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
namespace namespace

View file

@ -9,8 +9,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/journal.hpp"
#include "../mwdialogue/journal.hpp"
#include "interpretercontext.hpp" #include "interpretercontext.hpp"
#include "ref.hpp" #include "ref.hpp"