1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 23:09:42 +00:00

Issue #219: Begin of refactoring; added filter class (doesn't do anything yet)

This commit is contained in:
Marc Zinnschlag 2012-11-08 14:09:40 +01:00
parent 6c6c0dd1e3
commit 1502b3f6f8
4 changed files with 51 additions and 8 deletions

View file

@ -34,7 +34,7 @@ add_openmw_dir (mwgui
)
add_openmw_dir (mwdialogue
dialoguemanagerimp journalimp journalentry quest topic
dialoguemanagerimp journalimp journalentry quest topic filter
)
add_openmw_dir (mwscript

View file

@ -39,6 +39,8 @@
#include "../mwclass/npc.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "filter.hpp"
namespace
{
std::string toLower (const std::string& name)
@ -370,9 +372,7 @@ namespace MWDialogue
return true;
case '6': // dead
{
std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name))<<std::endl;
}
return selectCompare<int,int> (comp,
MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name)), select.mI);
@ -653,6 +653,8 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe
const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
Filter filter (actor);
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
{
@ -662,7 +664,7 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe
for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin());
iter!=it->mInfo.end(); ++iter)
{
if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true))
if (filter (*iter) && isMatching (actor, *iter) && functionFilter(mActor,*iter,true))
{
if (!iter->mSound.empty())
{
@ -755,6 +757,7 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe
const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
Filter filter (mActor);
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
@ -764,7 +767,7 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe
for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin());
iter!=it->mInfo.end(); ++iter)
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
mActorKnownTopics.push_back(toLower(it->mId));
//does the player know the topic?
@ -841,10 +844,12 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe
ESM::Dialogue ndialogue = mDialogueMap[keyword];
if(ndialogue.mType == ESM::Dialogue::Topic)
{
Filter filter (mActor);
for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin();
iter!=ndialogue.mInfo.end(); ++iter)
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
std::string text = iter->mResponse;
std::string script = iter->mResultScript;
@ -886,10 +891,12 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe
ESM::Dialogue ndialogue = mDialogueMap[mLastTopic];
if(ndialogue.mType == ESM::Dialogue::Topic)
{
Filter filter (mActor);
for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin();
iter!=ndialogue.mInfo.end(); ++iter)
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
mChoiceMap.clear();
mChoice = -1;

View file

@ -0,0 +1,10 @@
#include "filter.hpp"
MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {}
bool MWDialogue::Filter::operator() (const ESM::DialInfo& dialogue)
{
return true;
}

View file

@ -0,0 +1,26 @@
#ifndef GAME_MWDIALOGUE_FILTER_H
#define GAME_MWDIALOGUE_FILTER_H
#include "../mwworld/ptr.hpp"
namespace ESM
{
struct DialInfo;
}
namespace MWDialogue
{
class Filter
{
MWWorld::Ptr mActor;
public:
Filter (const MWWorld::Ptr& actor);
bool operator() (const ESM::DialInfo& dialogue);
///< \return does the dialogue match?
};
}
#endif