forked from teamnwah/openmw-tes3coop
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);
|
||||
mDialogueMap.clear();
|
||||
actorKnownTopics.clear();
|
||||
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||
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
|
||||
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;
|
||||
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||
{
|
||||
ESM::Dialogue ndialogue = it->second;
|
||||
if(ndialogue.type == ESM::Dialogue::Greeting)
|
||||
|
@ -702,8 +702,8 @@ namespace MWDialogue
|
|||
mChoice = -1;
|
||||
actorKnownTopics.clear();
|
||||
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
||||
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
|
||||
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||
{
|
||||
ESM::Dialogue ndialogue = it->second;
|
||||
if(ndialogue.type == ESM::Dialogue::Topic)
|
||||
|
@ -713,7 +713,7 @@ namespace MWDialogue
|
|||
{
|
||||
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?
|
||||
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
|
||||
{
|
||||
|
|
|
@ -183,6 +183,16 @@ void DialogueWindow::addText(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
template <typename X>
|
||||
struct RecListWithIDT : RecList
|
||||
|
|
|
@ -71,15 +71,13 @@ void ESMStore::load(ESMReader &esm)
|
|||
|
||||
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 = &iter->second;
|
||||
dialogue = d;
|
||||
}
|
||||
else
|
||||
dialogue = 0;
|
||||
|
|
|
@ -40,9 +40,9 @@ namespace ESMS
|
|||
RecListT<Clothing> clothes;
|
||||
RecListT<LoadCNTC> contChange;
|
||||
RecListT<Container> containers;
|
||||
RecListWithIDT<Creature> creatures;
|
||||
RecListWithIDT<Creature> creatures;
|
||||
RecListT<LoadCREC> creaChange;
|
||||
RecListT<Dialogue> dialogs;
|
||||
RecListCaseT<Dialogue> dialogs;
|
||||
RecListT<Door> doors;
|
||||
RecListT<Enchantment> enchants;
|
||||
RecListT<Faction> factions;
|
||||
|
@ -53,7 +53,7 @@ namespace ESMS
|
|||
RecListT<Light> lights;
|
||||
RecListT<Tool> lockpicks;
|
||||
RecListT<Miscellaneous> miscItems;
|
||||
RecListWithIDT<NPC> npcs;
|
||||
RecListWithIDT<NPC> npcs;
|
||||
RecListT<LoadNPCC> npcChange;
|
||||
RecListT<Probe> probes;
|
||||
RecListT<Race> races;
|
||||
|
|
Loading…
Reference in a new issue