diff options
author | Todd Stinson <stinson@lindenlab.com> | 2012-06-04 16:22:01 -0700 |
---|---|---|
committer | Todd Stinson <stinson@lindenlab.com> | 2012-06-04 16:22:01 -0700 |
commit | e85909aa9b52ac439f2886ca0048069fb9561893 (patch) | |
tree | eb7e5376f80c3a0adad98cc36799771ec96ba27c /indra/newview/llfloaterpathfindingcharacters.cpp | |
parent | ea23285f8b728bf52c8490610c610f4abd2d6957 (diff) |
Some class refactoring.
Diffstat (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp')
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.cpp | 174 |
1 files changed, 84 insertions, 90 deletions
diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 121cb85a6d..8b6f6aea1f 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -29,6 +29,7 @@ #include "llfloaterpathfindingcharacters.h" +#include "llcheckboxctrl.h" #include "llfloaterreg.h" #include "llfloaterpathfindingobjects.h" #include "llpathfindingcharacter.h" @@ -38,12 +39,6 @@ #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" @@ -53,22 +48,46 @@ LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::sInstan // LLFloaterPathfindingCharacters //--------------------------------------------------------------------------- +void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) +{ + unhideAnyCharacters(); + LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); +} + +BOOL LLFloaterPathfindingCharacters::isShowPhysicsCapsule() const +{ + return mShowPhysicsCapsuleCheckBox->get(); +} + +void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule) +{ + mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); +} + void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } -void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) +LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::getInstanceHandle() { - unhideAnyCharacters(); - LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance<LLFloaterPathfindingCharacters>("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; } LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), + mShowPhysicsCapsuleCheckBox(NULL), mBeaconColor(), - mSelfHandle(), - mShowPhysicsCapsuleCheckBox(NULL) + mSelfHandle() { mSelfHandle.bind(this); } @@ -115,6 +134,12 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa return scrollListData; } +void LLFloaterPathfindingCharacters::updateControls() +{ + LLFloaterPathfindingObjects::updateControls(); + updateStateOnEditFields(); +} + S32 LLFloaterPathfindingCharacters::getNameColumnIndex() const { return 0; @@ -131,6 +156,24 @@ LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() return objectListPtr; } +void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() +{ + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + if ( isShowPhysicsCapsule() ) + { + //We want to hide the VO and display the the objects physics capsule + gPipeline.hideObject( id ); + } + else + { + gPipeline.restoreHiddenObject( id ); + } + } +} + LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const { LLSD columns; @@ -169,107 +212,58 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi return element; } - -void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() +void LLFloaterPathfindingCharacters::updateStateOnEditFields() { - 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 ); - } - } -} + int numSelectedItems = getNumSelectedObjects();; + bool isEditEnabled = (numSelectedItems == 1); -BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) -{ - BOOL result = false; - if ( mShowPhysicsCapsuleCheckBox->get() ) - { - id = getUUIDFromSelection( pos ); - result = true; - } - else + mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); + if (!isEditEnabled) { - id.setNull(); + setShowPhysicsCapsule(FALSE); } - return result; } LLUUID LLFloaterPathfindingCharacters::getUUIDFromSelection( LLVector3& pos ) -{ - std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); - if ( selectedItems.size() > 1 ) - { - return LLUUID::null; - } - if (selectedItems.size() == 1) +{ + LLUUID uuid = LLUUID::null; + + if (getNumSelectedObjects() == 1) { - std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front(); - const LLScrollListItem *selectedItem = selectedItemRef; - llassert(mObjectList != NULL); - LLViewerObject *viewerObject = gObjectList.findObject( selectedItem->getUUID() ); + LLPathfindingObjectPtr selectedObjectPtr = getFirstSelectedObject(); + uuid = selectedObjectPtr->getUUID(); + LLViewerObject *viewerObject = gObjectList.findObject(uuid); if ( viewerObject != NULL ) { pos = viewerObject->getRenderPosition(); } - //llinfos<<"id : "<<selectedItem->getUUID()<<llendl; - return selectedItem->getUUID(); } - return LLUUID::null; + return uuid; } -LLHandle<LLFloaterPathfindingCharacters> LLFloaterPathfindingCharacters::getInstanceHandle() +void LLFloaterPathfindingCharacters::unhideAnyCharacters() { - if ( sInstanceHandle.isDead() ) + LLPathfindingObjectListPtr objectListPtr = getSelectedObjects(); + for (LLPathfindingObjectList::const_iterator objectIter = objectListPtr->begin(); + objectIter != objectListPtr->end(); ++objectIter) { - LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance<LLFloaterPathfindingCharacters>("pathfinding_characters"); - if (floaterInstance != NULL) - { - sInstanceHandle = floaterInstance->mSelfHandle; - } + LLPathfindingObjectPtr objectPtr = objectIter->second; + gPipeline.restoreHiddenObject(objectPtr->getUUID()); } - - return sInstanceHandle; -} - -void LLFloaterPathfindingCharacters::updateStateOnEditFields() -{ - int numSelectedItems = mObjectsScrollList->getNumSelected(); - bool isEditEnabled = (numSelectedItems > 0); - - mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); - - LLFloaterPathfindingObjects::updateStateOnEditFields(); } - -void LLFloaterPathfindingCharacters::unhideAnyCharacters( ) +BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) { - std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - uuid_vec_t selectedUUIDs; - if (numSelectedItems > 0) + BOOL result = false; + if ( isShowPhysicsCapsule() ) + { + id = getUUIDFromSelection( pos ); + result = true; + } + else { - for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) - { - const LLScrollListItem *listItem = *itemIter; - gPipeline.restoreHiddenObject( listItem->getUUID() ); - } + id.setNull(); } + return result; } |