integrated name-lookup into ape's code; added missing implementation of a function

pull/7/head
Marc Zinnschlag 15 years ago
parent 5827591d05
commit 052d049a6c

@ -24,6 +24,7 @@
#include "mwworld/world.hpp"
#include "mwworld/ptr.hpp"
#include "mwworld/environment.hpp"
#include "mwworld/class.hpp"
#include "mwclass/classes.hpp"
@ -74,8 +75,21 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
if (focusFrameCounter++ == focusUpdateFrame)
{
std::pair<std::string, float> handle = mEnvironment.mWorld->getMWScene()->getFacedHandle();
std::cout << "Object: " << handle.first << ", distance: " << handle.second << std::endl;
std::string name;
if (!handle.first.empty())
{
// TODO compare handle.second with max activation range (from a GMST)
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle.first);
if (!ptr.isEmpty())
name = MWWorld::Class::get (ptr).getName (ptr);
}
if (!name.empty())
std::cout << "Object: " << name << ", distance: " << handle.second << std::endl;
focusFrameCounter = 0;
}
@ -244,7 +258,7 @@ void OMW::Engine::go()
*mEnvironment.mWindowManager, mDebug);
focusFrameCounter = 0;
std::cout << "\nPress Q/ESC or close window to exit.\n";
mOgre.getRoot()->addFrameListener (this);

@ -42,6 +42,15 @@ namespace
ESMS::LiveCellRef<T, MWWorld::RefData> *searchViaHandle (const std::string& handle,
ESMS::CellRefList<T, MWWorld::RefData>& refList)
{
typedef typename ESMS::CellRefList<T, MWWorld::RefData>::List::iterator iterator;
for (iterator iter (refList.list.begin()); iter!=refList.list.end(); ++iter)
{
if (iter->mData.getHandle()==handle)
{
return &*iter;
}
}
return 0;
}

Loading…
Cancel
Save