diff options
Diffstat (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp')
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.cpp | 111 |
1 files changed, 110 insertions, 1 deletions
diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 59f54c12bf..8915683b6d 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -38,6 +38,17 @@ #include "llsd.h" #include "lluicolortable.h" +#include "llbutton.h" +#include "llcheckboxctrl.h" +#include "llfloater.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "llselectmgr.h" +#include "pipeline.h" +#include "llviewerobjectlist.h" + +LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::sInstanceHandle; + //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters //--------------------------------------------------------------------------- @@ -46,11 +57,17 @@ void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } +void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) +{ +} LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), - mBeaconColor() + mBeaconColor(), + mSelfHandle(), + mShowPhysicsCapsuleCheckBox(NULL) { + mSelfHandle.bind(this); } LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() @@ -61,6 +78,10 @@ BOOL LLFloaterPathfindingCharacters::postBuild() { mBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingCharacterBeaconColor"); + mShowPhysicsCapsuleCheckBox = findChild<LLCheckBoxCtrl>("show_physics_capsule"); + llassert(mShowPhysicsCapsuleCheckBox != NULL); + mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked, this)); + return LLFloaterPathfindingObjects::postBuild(); } @@ -137,3 +158,91 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi return element; } + + +void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() +{ + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + //We want to hide the VO and display the the objects physics capsule + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + gPipeline.hideObject( id ); + } + } + else + { + //We want to restore the selected objects vo and disable the physics capsule rendering + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + gPipeline.restoreHiddenObject( id ); + } + } +} + +BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) +{ + BOOL result = false; + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + id = getUUIDFromSelection( pos ); + result = true; + } + else + { + id.setNull(); + } + return result; +} + +LLUUID LLFloaterPathfindingCharacters::getUUIDFromSelection( LLVector3& pos ) +{ + std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); + if ( selectedItems.size() > 1 ) + { + return LLUUID::null; + } + if (selectedItems.size() == 1) + { + std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front(); + const LLScrollListItem *selectedItem = selectedItemRef; + llassert(mObjectList != NULL); + LLViewerObject *viewerObject = gObjectList.findObject( selectedItem->getUUID() ); + if ( viewerObject != NULL ) + { + pos = viewerObject->getRenderPosition(); + } + //llinfos<<"id : "<<selectedItem->getUUID()<<llendl; + return selectedItem->getUUID(); + } + + return LLUUID::null; +} + +LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::getInstanceHandle() +{ + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance<LLFloaterPathfindingCharacters>("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; +} + +void LLFloaterPathfindingCharacters::updateStateOnEditFields() +{ + int numSelectedItems = mObjectsScrollList->getNumSelected(); + bool isEditEnabled = (numSelectedItems > 0); + + mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); + + LLFloaterPathfindingObjects::updateStateOnEditFields(); +} |