searchPtrViaHandle

This commit is contained in:
scrawl 2012-10-19 19:48:02 +02:00
parent 28cc480ce1
commit d76522e7a4
6 changed files with 18 additions and 12 deletions

View file

@ -424,7 +424,7 @@ void OMW::Engine::activate()
if (handle.empty())
return;
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle);
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaHandle (handle);
if (ptr.isEmpty())
return;

View file

@ -142,6 +142,9 @@ namespace MWBase
virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
///< Return a pointer to a liveCellRef with the given Ogre handle.
virtual MWWorld::Ptr searchPtrViaHandle (const std::string& handle) = 0;
///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found
/// \todo enable reference in the OGRE scene
virtual void enable (const MWWorld::Ptr& ptr) = 0;

View file

@ -245,15 +245,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
return;
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
MWWorld::Ptr object;
try
{
object = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle);
}
catch (std::exception& /* e */)
{
return;
}
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
if (mode == GM_Console)
MWBase::Environment::get().getWindowManager()->getConsole()->setSelectedObject(object);

View file

@ -80,7 +80,7 @@ void ToolTips::onFrame(float frameDuration)
{
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
mFocusObject = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle);
mFocusObject = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
if (mFocusObject.isEmpty ())
return;

View file

@ -326,6 +326,14 @@ namespace MWWorld
}
Ptr World::getPtrViaHandle (const std::string& handle)
{
Ptr res = searchPtrViaHandle (handle);
if (res.isEmpty ())
throw std::runtime_error ("unknown Ogre handle: " + handle);
return res;
}
Ptr World::searchPtrViaHandle (const std::string& handle)
{
if (mPlayer->getPlayer().getRefData().getHandle()==handle)
return mPlayer->getPlayer();
@ -850,7 +858,7 @@ namespace MWWorld
mWeatherManager->update (duration);
// inform the GUI about focused object
MWWorld::Ptr object = getPtrViaHandle(mFacedHandle);
MWWorld::Ptr object = searchPtrViaHandle(mFacedHandle);
MWBase::Environment::get().getWindowManager()->setFocusObject(object);

View file

@ -163,6 +163,9 @@ namespace MWWorld
virtual Ptr getPtrViaHandle (const std::string& handle);
///< Return a pointer to a liveCellRef with the given Ogre handle.
virtual Ptr searchPtrViaHandle (const std::string& handle);
///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found
virtual void enable (const Ptr& ptr);
virtual void disable (const Ptr& ptr);