forked from mirror/openmw-tes3mp
Merge remote branch 'scrawl/topic_case' into next
This commit is contained in:
commit
5f09f2bfc6
5 changed files with 94 additions and 17 deletions
|
@ -549,10 +549,10 @@ namespace MWDialogue
|
||||||
mCompilerContext.setExtensions (&extensions);
|
mCompilerContext.setExtensions (&extensions);
|
||||||
mDialogueMap.clear();
|
mDialogueMap.clear();
|
||||||
actorKnownTopics.clear();
|
actorKnownTopics.clear();
|
||||||
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||||
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||||
{
|
{
|
||||||
mDialogueMap[it->first] = it->second;
|
mDialogueMap[toLower(it->first)] = it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,8 +602,8 @@ namespace MWDialogue
|
||||||
//greeting
|
//greeting
|
||||||
bool greetingFound = false;
|
bool greetingFound = false;
|
||||||
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||||
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||||
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||||
{
|
{
|
||||||
ESM::Dialogue ndialogue = it->second;
|
ESM::Dialogue ndialogue = it->second;
|
||||||
if(ndialogue.type == ESM::Dialogue::Greeting)
|
if(ndialogue.type == ESM::Dialogue::Greeting)
|
||||||
|
@ -702,8 +702,8 @@ namespace MWDialogue
|
||||||
mChoice = -1;
|
mChoice = -1;
|
||||||
actorKnownTopics.clear();
|
actorKnownTopics.clear();
|
||||||
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
||||||
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||||
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||||
{
|
{
|
||||||
ESM::Dialogue ndialogue = it->second;
|
ESM::Dialogue ndialogue = it->second;
|
||||||
if(ndialogue.type == ESM::Dialogue::Topic)
|
if(ndialogue.type == ESM::Dialogue::Topic)
|
||||||
|
@ -713,7 +713,7 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
|
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
|
||||||
{
|
{
|
||||||
actorKnownTopics.push_back(it->first);
|
actorKnownTopics.push_back(toLower(it->first));
|
||||||
//does the player know the topic?
|
//does the player know the topic?
|
||||||
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
|
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -183,6 +183,16 @@ void DialogueWindow::addText(std::string text)
|
||||||
|
|
||||||
void DialogueWindow::addTitle(std::string text)
|
void DialogueWindow::addTitle(std::string text)
|
||||||
{
|
{
|
||||||
|
// This is called from the dialogue manager, so text is
|
||||||
|
// case-smashed - thus we have to retrieve the correct case
|
||||||
|
// of the text through the topic list.
|
||||||
|
for (size_t i=0; i<topicsList->getItemCount(); ++i)
|
||||||
|
{
|
||||||
|
std::string item = topicsList->getItemNameAt(i);
|
||||||
|
if (lower_string(item) == text)
|
||||||
|
text = item;
|
||||||
|
}
|
||||||
|
|
||||||
history->addDialogHeading(text);
|
history->addDialogHeading(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,75 @@ namespace ESMS
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Same as RecListT, but does not case-smash the IDs
|
||||||
|
// Note that lookups (search or find) are still case insensitive
|
||||||
|
template <typename X>
|
||||||
|
struct RecListCaseT : RecList
|
||||||
|
{
|
||||||
|
virtual ~RecListCaseT() {}
|
||||||
|
|
||||||
|
typedef std::map<std::string,X> MapType;
|
||||||
|
|
||||||
|
MapType list;
|
||||||
|
|
||||||
|
// Load one object of this type
|
||||||
|
void load(ESMReader &esm, const std::string &id)
|
||||||
|
{
|
||||||
|
//std::string id2 = toLower (id);
|
||||||
|
|
||||||
|
list[id].load(esm);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the given object ID, or return NULL if not found.
|
||||||
|
const X* search(const std::string &id) const
|
||||||
|
{
|
||||||
|
std::string id2 = toLower (id);
|
||||||
|
|
||||||
|
for (typename MapType::const_iterator iter = list.begin();
|
||||||
|
iter != list.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (toLower(iter->first) == id2)
|
||||||
|
return &iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// non-const version
|
||||||
|
X* search(const std::string &id)
|
||||||
|
{
|
||||||
|
std::string id2 = toLower (id);
|
||||||
|
|
||||||
|
for (typename MapType::iterator iter = list.begin();
|
||||||
|
iter != list.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (toLower(iter->first) == id2)
|
||||||
|
return &iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the given object ID (throws an exception if not found)
|
||||||
|
const X* find(const std::string &id) const
|
||||||
|
{
|
||||||
|
const X *object = search (id);
|
||||||
|
|
||||||
|
if (!object)
|
||||||
|
throw std::runtime_error ("object " + id + " not found");
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize() { return list.size(); }
|
||||||
|
|
||||||
|
virtual void listIdentifier (std::vector<std::string>& identifier) const
|
||||||
|
{
|
||||||
|
for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter)
|
||||||
|
identifier.push_back (iter->first);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// Modified version of RecListT for records, that need to store their own ID
|
/// Modified version of RecListT for records, that need to store their own ID
|
||||||
template <typename X>
|
template <typename X>
|
||||||
struct RecListWithIDT : RecList
|
struct RecListWithIDT : RecList
|
||||||
|
|
|
@ -71,15 +71,13 @@ void ESMStore::load(ESMReader &esm)
|
||||||
|
|
||||||
if (n.val==ESM::REC_DIAL)
|
if (n.val==ESM::REC_DIAL)
|
||||||
{
|
{
|
||||||
RecListT<Dialogue>& recList = static_cast<RecListT<Dialogue>& > (*it->second);
|
RecListCaseT<Dialogue>& recList = static_cast<RecListCaseT<Dialogue>& > (*it->second);
|
||||||
|
|
||||||
id = recList.toLower (id);
|
ESM::Dialogue* d = recList.search (id);
|
||||||
|
|
||||||
RecListT<Dialogue>::MapType::iterator iter = recList.list.find (id);
|
assert (d != NULL);
|
||||||
|
|
||||||
assert (iter!=recList.list.end());
|
dialogue = d;
|
||||||
|
|
||||||
dialogue = &iter->second;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dialogue = 0;
|
dialogue = 0;
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace ESMS
|
||||||
RecListT<Container> containers;
|
RecListT<Container> containers;
|
||||||
RecListWithIDT<Creature> creatures;
|
RecListWithIDT<Creature> creatures;
|
||||||
RecListT<LoadCREC> creaChange;
|
RecListT<LoadCREC> creaChange;
|
||||||
RecListT<Dialogue> dialogs;
|
RecListCaseT<Dialogue> dialogs;
|
||||||
RecListT<Door> doors;
|
RecListT<Door> doors;
|
||||||
RecListT<Enchantment> enchants;
|
RecListT<Enchantment> enchants;
|
||||||
RecListT<Faction> factions;
|
RecListT<Faction> factions;
|
||||||
|
|
Loading…
Reference in a new issue