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 | |
parent | ea23285f8b728bf52c8490610c610f4abd2d6957 (diff) |
Some class refactoring.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.cpp | 174 | ||||
-rw-r--r-- | indra/newview/llfloaterpathfindingcharacters.h | 39 | ||||
-rw-r--r-- | indra/newview/llfloaterpathfindingobjects.h | 3 |
3 files changed, 108 insertions, 108 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; } diff --git a/indra/newview/llfloaterpathfindingcharacters.h b/indra/newview/llfloaterpathfindingcharacters.h index ced72dadee..f62766df22 100644 --- a/indra/newview/llfloaterpathfindingcharacters.h +++ b/indra/newview/llfloaterpathfindingcharacters.h @@ -29,6 +29,7 @@ #define LL_LLFLOATERPATHFINDINGCHARACTERS_H #include "llfloaterpathfindingobjects.h" +#include "llhandle.h" #include "llpathfindingobjectlist.h" #include "v4color.h" @@ -38,9 +39,17 @@ class LLSD; class LLFloaterPathfindingCharacters : public LLFloaterPathfindingObjects { public: - static void openCharactersViewer(); - /*virtual*/ void onClose(bool pIsAppQuitting); - void updateStateOnEditFields(); + virtual void onClose(bool pIsAppQuitting); + + BOOL isShowPhysicsCapsule() const; + void setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule); + + BOOL isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ); + + static void openCharactersViewer(); + static LLHandle<LLFloaterPathfindingCharacters> getInstanceHandle(); + + protected: friend class LLFloaterReg; @@ -53,32 +62,30 @@ protected: virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr); + virtual void updateControls(); + virtual S32 getNameColumnIndex() const; virtual const LLColor4 &getBeaconColor() const; virtual LLPathfindingObjectListPtr getEmptyObjectList() const; - - void unhideAnyCharacters(); - private: - LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const; + void onShowPhysicsCapsuleClicked(); - LLColor4 mBeaconColor; - - LLUUID getUUIDFromSelection( LLVector3& pos ); + LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const; + void updateStateOnEditFields(); + LLUUID getUUIDFromSelection( LLVector3& pos ); + void unhideAnyCharacters(); + + LLCheckBoxCtrl *mShowPhysicsCapsuleCheckBox; + + LLColor4 mBeaconColor; -public: - BOOL isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ); - void onShowPhysicsCapsuleClicked(); LLRootHandle<LLFloaterPathfindingCharacters> mSelfHandle; static LLHandle<LLFloaterPathfindingCharacters> sInstanceHandle; - static LLHandle<LLFloaterPathfindingCharacters> getInstanceHandle(); public: - LLCheckBoxCtrl *mShowPhysicsCapsuleCheckBox; - }; #endif // LL_LLFLOATERPATHFINDINGCHARACTERS_H diff --git a/indra/newview/llfloaterpathfindingobjects.h b/indra/newview/llfloaterpathfindingobjects.h index 604d026f29..cf418b3b71 100644 --- a/indra/newview/llfloaterpathfindingobjects.h +++ b/indra/newview/llfloaterpathfindingobjects.h @@ -52,7 +52,6 @@ public: virtual void onOpen(const LLSD &pKey); virtual void onClose(bool pIsAppQuitting); virtual void draw(); - virtual void updateStateOnEditFields(); protected: friend class LLFloaterReg; @@ -126,11 +125,11 @@ private: void updateMessagingStatus(); void updateStateOnListActionControls(); + void updateStateOnEditFields(); void updateOnScrollListChange(); LLPathfindingObjectPtr findObject(const LLScrollListItem *pListItem) const; -protected: LLScrollListCtrl *mObjectsScrollList; LLTextBase *mMessagingStatus; LLButton *mRefreshListButton; |