storing topic name in MWDialogue::Topic (avoids a lookup in the GUI and also serves as preparation for better localisation support in OpenMW 1.1)

actorid
Marc Zinnschlag 11 years ago
parent eed46960fe
commit 177aab536d

@ -16,7 +16,7 @@ namespace MWDialogue
: Topic (topic), mIndex (0), mFinished (false)
{}
const std::string Quest::getName() const
std::string Quest::getName() const
{
const ESM::Dialogue *dialogue =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);

@ -17,7 +17,7 @@ namespace MWDialogue
Quest (const std::string& topic);
const std::string getName() const;
virtual std::string getName() const;
///< May be an empty string
int getIndex() const;

@ -1,6 +1,9 @@
#include "topic.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWDialogue
@ -9,7 +12,8 @@ namespace MWDialogue
{}
Topic::Topic (const std::string& topic)
: mTopic (topic)
: mTopic (topic), mName (
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic)->mId)
{}
Topic::~Topic()
@ -27,6 +31,11 @@ namespace MWDialogue
mEntries.push_back (entry.mInfoId);
}
std::string Topic::getName() const
{
return mName;
}
Topic::TEntryIter Topic::begin() const
{
return mEntries.begin();

@ -19,6 +19,7 @@ namespace MWDialogue
protected:
std::string mTopic;
std::string mName;
TEntryContainer mEntries; // info-IDs
public:
@ -34,7 +35,7 @@ namespace MWDialogue
///
/// \note Redundant entries are ignored.
std::string const & getName () const { return mTopic; }
virtual std::string getName () const;
TEntryIter begin() const;
///< Iterator pointing to the begin of the journal for this topic.

@ -288,9 +288,7 @@ struct JournalViewModelImpl : JournalViewModel
void visitTopicName (TopicId topicId, boost::function <void (Utf8Span)> visitor) const
{
MWDialogue::Topic const & topic = * reinterpret_cast <MWDialogue::Topic const *> (topicId);
// This is to get the correct case for the topic
const std::string& name = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic.getName())->mId;
visitor (toUtf8Span (name));
visitor (toUtf8Span (topic.getName()));
}
void visitTopicNamesStartingWith (char character, boost::function < void (TopicId , Utf8Span) > visitor) const
@ -302,10 +300,7 @@ struct JournalViewModelImpl : JournalViewModel
if (i->first [0] != std::tolower (character, mLocale))
continue;
// This is to get the correct case for the topic
const std::string& name = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(i->first)->mId;
visitor (TopicId (&i->second), toUtf8Span (name));
visitor (TopicId (&i->second), toUtf8Span (i->second.getName()));
}
}

Loading…
Cancel
Save