2011-04-04 09:16:56 +00:00
|
|
|
|
2012-08-09 10:56:03 +00:00
|
|
|
#include "journalimp.hpp"
|
2011-04-04 09:16:56 +00:00
|
|
|
|
2012-08-12 12:36:46 +00:00
|
|
|
#include <components/esm_store/store.hpp>
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
2011-04-04 09:23:15 +00:00
|
|
|
|
2012-03-19 18:18:08 +00:00
|
|
|
#include "../mwgui/window_manager.hpp"
|
|
|
|
#include "../mwgui/messagebox.hpp"
|
|
|
|
|
2011-04-04 09:16:56 +00:00
|
|
|
namespace MWDialogue
|
|
|
|
{
|
2011-04-26 18:08:37 +00:00
|
|
|
Quest& Journal::getQuest (const std::string& id)
|
|
|
|
{
|
|
|
|
TQuestContainer::iterator iter = mQuests.find (id);
|
|
|
|
|
|
|
|
if (iter==mQuests.end())
|
|
|
|
{
|
|
|
|
std::pair<TQuestContainer::iterator, bool> result =
|
|
|
|
mQuests.insert (std::make_pair (id, Quest (id)));
|
|
|
|
|
|
|
|
iter = result.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
Journal::Journal()
|
2011-04-04 09:16:56 +00:00
|
|
|
{}
|
|
|
|
|
2011-04-04 09:23:15 +00:00
|
|
|
void Journal::addEntry (const std::string& id, int index)
|
|
|
|
{
|
2012-07-03 10:30:50 +00:00
|
|
|
StampedJournalEntry entry = StampedJournalEntry::makeFromQuest (id, index);
|
2011-04-26 18:08:37 +00:00
|
|
|
|
|
|
|
mJournal.push_back (entry);
|
|
|
|
|
|
|
|
Quest& quest = getQuest (id);
|
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
quest.addEntry (entry); // we are doing slicing on purpose here
|
2012-04-23 13:27:03 +00:00
|
|
|
|
2012-03-19 18:18:08 +00:00
|
|
|
std::vector<std::string> empty;
|
2012-05-01 19:49:00 +00:00
|
|
|
std::string notification = MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sJournalEntry")->str;
|
2012-04-23 13:27:03 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox (notification, empty);
|
2011-04-04 09:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Journal::setJournalIndex (const std::string& id, int index)
|
|
|
|
{
|
2011-04-26 18:08:37 +00:00
|
|
|
Quest& quest = getQuest (id);
|
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
quest.setIndex (index);
|
2011-04-04 09:23:15 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 18:48:36 +00:00
|
|
|
void Journal::addTopic (const std::string& topicId, const std::string& infoId)
|
|
|
|
{
|
|
|
|
TTopicContainer::iterator iter = mTopics.find (topicId);
|
|
|
|
|
|
|
|
if (iter==mTopics.end())
|
|
|
|
{
|
|
|
|
std::pair<TTopicContainer::iterator, bool> result
|
|
|
|
= mTopics.insert (std::make_pair (topicId, Topic (topicId)));
|
|
|
|
|
|
|
|
iter = result.first;
|
|
|
|
}
|
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
iter->second.addEntry (JournalEntry (topicId, infoId));
|
2011-04-26 18:48:36 +00:00
|
|
|
}
|
|
|
|
|
2011-04-04 09:23:15 +00:00
|
|
|
int Journal::getJournalIndex (const std::string& id) const
|
|
|
|
{
|
2012-03-18 18:05:35 +00:00
|
|
|
TQuestContainer::const_iterator iter = mQuests.find (id);
|
|
|
|
|
|
|
|
if (iter==mQuests.end())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return iter->second.getIndex();
|
2011-04-04 09:23:15 +00:00
|
|
|
}
|
2011-04-19 09:02:22 +00:00
|
|
|
|
|
|
|
Journal::TEntryIter Journal::begin() const
|
|
|
|
{
|
|
|
|
return mJournal.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
Journal::TEntryIter Journal::end() const
|
|
|
|
{
|
|
|
|
return mJournal.end();
|
|
|
|
}
|
2011-04-26 18:08:37 +00:00
|
|
|
|
|
|
|
Journal::TQuestIter Journal::questBegin() const
|
|
|
|
{
|
|
|
|
return mQuests.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
Journal::TQuestIter Journal::questEnd() const
|
|
|
|
{
|
|
|
|
return mQuests.end();
|
|
|
|
}
|
2011-04-26 18:48:36 +00:00
|
|
|
|
|
|
|
Journal::TTopicIter Journal::topicBegin() const
|
|
|
|
{
|
|
|
|
return mTopics.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
Journal::TTopicIter Journal::topicEnd() const
|
|
|
|
{
|
|
|
|
return mTopics.end();
|
|
|
|
}
|
2011-04-04 09:16:56 +00:00
|
|
|
}
|