mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 16:09:41 +00:00
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)
This commit is contained in:
parent
eed46960fe
commit
177aab536d
5 changed files with 16 additions and 11 deletions
|
@ -16,7 +16,7 @@ namespace MWDialogue
|
||||||
: Topic (topic), mIndex (0), mFinished (false)
|
: Topic (topic), mIndex (0), mFinished (false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const std::string Quest::getName() const
|
std::string Quest::getName() const
|
||||||
{
|
{
|
||||||
const ESM::Dialogue *dialogue =
|
const ESM::Dialogue *dialogue =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic);
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
Quest (const std::string& topic);
|
Quest (const std::string& topic);
|
||||||
|
|
||||||
const std::string getName() const;
|
virtual std::string getName() const;
|
||||||
///< May be an empty string
|
///< May be an empty string
|
||||||
|
|
||||||
int getIndex() const;
|
int getIndex() const;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
|
||||||
#include "topic.hpp"
|
#include "topic.hpp"
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
|
@ -9,7 +12,8 @@ namespace MWDialogue
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Topic::Topic (const std::string& topic)
|
Topic::Topic (const std::string& topic)
|
||||||
: mTopic (topic)
|
: mTopic (topic), mName (
|
||||||
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic)->mId)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Topic::~Topic()
|
Topic::~Topic()
|
||||||
|
@ -27,6 +31,11 @@ namespace MWDialogue
|
||||||
mEntries.push_back (entry.mInfoId);
|
mEntries.push_back (entry.mInfoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Topic::getName() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
Topic::TEntryIter Topic::begin() const
|
Topic::TEntryIter Topic::begin() const
|
||||||
{
|
{
|
||||||
return mEntries.begin();
|
return mEntries.begin();
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace MWDialogue
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::string mTopic;
|
std::string mTopic;
|
||||||
|
std::string mName;
|
||||||
TEntryContainer mEntries; // info-IDs
|
TEntryContainer mEntries; // info-IDs
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -34,7 +35,7 @@ namespace MWDialogue
|
||||||
///
|
///
|
||||||
/// \note Redundant entries are ignored.
|
/// \note Redundant entries are ignored.
|
||||||
|
|
||||||
std::string const & getName () const { return mTopic; }
|
virtual std::string getName () const;
|
||||||
|
|
||||||
TEntryIter begin() const;
|
TEntryIter begin() const;
|
||||||
///< Iterator pointing to the begin of the journal for this topic.
|
///< 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
|
void visitTopicName (TopicId topicId, boost::function <void (Utf8Span)> visitor) const
|
||||||
{
|
{
|
||||||
MWDialogue::Topic const & topic = * reinterpret_cast <MWDialogue::Topic const *> (topicId);
|
MWDialogue::Topic const & topic = * reinterpret_cast <MWDialogue::Topic const *> (topicId);
|
||||||
// This is to get the correct case for the topic
|
visitor (toUtf8Span (topic.getName()));
|
||||||
const std::string& name = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic.getName())->mId;
|
|
||||||
visitor (toUtf8Span (name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void visitTopicNamesStartingWith (char character, boost::function < void (TopicId , Utf8Span) > visitor) const
|
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))
|
if (i->first [0] != std::tolower (character, mLocale))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// This is to get the correct case for the topic
|
visitor (TopicId (&i->second), toUtf8Span (i->second.getName()));
|
||||||
const std::string& name = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(i->first)->mId;
|
|
||||||
|
|
||||||
visitor (TopicId (&i->second), toUtf8Span (name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue