From 074acc412548c29729f1782f2803e426507d7115 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 10 Jun 2009 10:53:54 -0700 Subject: Applied MJM's tree and grass pulldown list from the Hippo Viewer --- linden/indra/newview/app_settings/grass.xml | 14 ++-- linden/indra/newview/app_settings/settings.xml | 32 ++++++++-- linden/indra/newview/app_settings/trees.xml | 32 +++++----- linden/indra/newview/llfloatertools.cpp | 74 +++++++++++++++++++++- linden/indra/newview/llfloatertools.h | 4 ++ linden/indra/newview/lltoolplacer.cpp | 18 +++++- linden/indra/newview/llvograss.cpp | 11 +++- linden/indra/newview/llvograss.h | 3 + linden/indra/newview/llvotree.cpp | 14 +++- linden/indra/newview/llvotree.h | 3 + .../skins/default/xui/en-us/floater_tools.xml | 3 + 11 files changed, 172 insertions(+), 36 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/app_settings/grass.xml b/linden/indra/newview/app_settings/grass.xml index 4fc3b79..bdfa603 100644 --- a/linden/indra/newview/app_settings/grass.xml +++ b/linden/indra/newview/app_settings/grass.xml @@ -1,47 +1,47 @@ + - \ No newline at end of file diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index cce09e2..4947c45 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -4236,16 +4236,38 @@ default LanguageIsPublic - + Comment - Let other residents see our language information + Let other residents see our language information Persist - 1 + 1 Type - Boolean + Boolean Value - 1 + 1 + LastGrass + + Comment + The last grass selected in the create dialog + Persist + 1 + Type + String + Value + Random + + LastTree + + Comment + The last tree selected in the create dialog + Persist + 1 + Type + String + Value + Random + LastFeatureVersion Comment diff --git a/linden/indra/newview/app_settings/trees.xml b/linden/indra/newview/app_settings/trees.xml index 213ee85..36ffa62 100644 --- a/linden/indra/newview/app_settings/trees.xml +++ b/linden/indra/newview/app_settings/trees.xml @@ -1,24 +1,24 @@ - + - - - - - - - - + + + + + + + + - - - - + + + + - - - + + + diff --git a/linden/indra/newview/llfloatertools.cpp b/linden/indra/newview/llfloatertools.cpp index e723ba1..2fc4c71 100644 --- a/linden/indra/newview/llfloatertools.cpp +++ b/linden/indra/newview/llfloatertools.cpp @@ -77,6 +77,8 @@ #include "llviewerwindow.h" #include "llviewercontrol.h" #include "llviewerjoystick.h" +#include "llvograss.h" +#include "llvotree.h" #include "lluictrlfactory.h" // Globals @@ -276,10 +278,14 @@ BOOL LLFloaterTools::postBuild() { found->setClickedCallback(setObjectType,toolData[t]); mButtons.push_back( found ); - }else{ + } + else + { llwarns << "Tool button not found! DOA Pending." << llendl; } } + mComboTreesGrass = getChild("trees_grass"); + childSetCommitCallback("trees_grass", onSelectTreesGrass, (void*)0); mCheckCopySelection = getChild("checkbox copy selection"); childSetValue("checkbox copy selection",(BOOL)gSavedSettings.getBOOL("CreateToolCopySelection")); mCheckSticky = getChild("checkbox sticky"); @@ -381,6 +387,7 @@ LLFloaterTools::LLFloaterTools() mBtnDuplicate(NULL), mBtnDuplicateInPlace(NULL), + mComboTreesGrass(NULL), mCheckSticky(NULL), mCheckCopySelection(NULL), mCheckCopyCenters(NULL), @@ -659,6 +666,8 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask) mBtnCreate ->setToggleState( tool == LLToolCompCreate::getInstance() ); + updateTreeGrassCombo(create_visible); + if (mCheckCopySelection && mCheckCopySelection->get()) { @@ -1004,6 +1013,7 @@ void LLFloaterTools::setObjectType( void* data ) LLPCode pcode = *(LLPCode*) data; LLToolPlacer::setObjectType( pcode ); gSavedSettings.setBOOL("CreateToolCopySelection", FALSE); + gFloaterTools->updateTreeGrassCombo(true); gFocusMgr.setMouseCapture(NULL); } @@ -1026,3 +1036,65 @@ void LLFloaterTools::onFocusReceived() LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); LLFloater::onFocusReceived(); } + +void LLFloaterTools::updateTreeGrassCombo(bool visible) +{ + if (visible) + { + LLPCode pcode = LLToolPlacer::getObjectType(); + std::map::iterator it, end; + std::string selected; + if (pcode == LLToolPlacerPanel::sTree) + { + selected = gSavedSettings.getString("LastTree"); + it = LLVOTree::sSpeciesNames.begin(); + end = LLVOTree::sSpeciesNames.end(); + } + else if (pcode == LLToolPlacerPanel::sGrass) + { + selected = gSavedSettings.getString("LastGrass"); + it = LLVOGrass::sSpeciesNames.begin(); + end = LLVOGrass::sSpeciesNames.end(); + } + else + { + mComboTreesGrass->removeall(); + mComboTreesGrass->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label + mComboTreesGrass->setEnabled(false); + return; + } + + mComboTreesGrass->removeall(); + mComboTreesGrass->add("Random"); + + int select = 0, i = 0; + + while (it != end) + { + const std::string &species = it->first; + mComboTreesGrass->add(species); ++i; + if (species == selected) select = i; + ++it; + } + // if saved species not found, default to "Random" + mComboTreesGrass->selectNthItem(select); + mComboTreesGrass->setEnabled(true); + } + + mComboTreesGrass->setVisible(visible); +} + +// static +void LLFloaterTools::onSelectTreesGrass(LLUICtrl*, void*) +{ + const std::string &selected = gFloaterTools->mComboTreesGrass->getValue(); + LLPCode pcode = LLToolPlacer::getObjectType(); + if (pcode == LLToolPlacerPanel::sTree) + { + gSavedSettings.setString("LastTree", selected); + } + else if (pcode == LLToolPlacerPanel::sGrass) + { + gSavedSettings.setString("LastGrass", selected); + } +} diff --git a/linden/indra/newview/llfloatertools.h b/linden/indra/newview/llfloatertools.h index 9d555d1..360b1df 100644 --- a/linden/indra/newview/llfloatertools.h +++ b/linden/indra/newview/llfloatertools.h @@ -153,6 +153,7 @@ public: LLButton *mBtnDuplicateInPlace; // Create buttons + LLComboBox *mComboTreesGrass; LLCheckBoxCtrl *mCheckSticky; LLCheckBoxCtrl *mCheckCopySelection; LLCheckBoxCtrl *mCheckCopyCenters; @@ -194,6 +195,9 @@ private: S32 mLargeHeight; std::map mStatusText; + + void updateTreeGrassCombo(bool visible); + static void onSelectTreesGrass(LLUICtrl*, void*); }; extern LLFloaterTools *gFloaterTools; diff --git a/linden/indra/newview/lltoolplacer.cpp b/linden/indra/newview/lltoolplacer.cpp index dda21dd..297556e 100644 --- a/linden/indra/newview/lltoolplacer.cpp +++ b/linden/indra/newview/lltoolplacer.cpp @@ -156,6 +156,20 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj, } +static S32 getTreeGrassSpecies(std::map &table, const char *control, S32 max) +{ + const std::string &species = gSavedSettings.getString(control); + std::map::iterator it; + it = table.find(species); + if (it != table.end()) { + return it->second; + } else { + // if saved species not found, default to "Random" + return (rand() % max); + } +} + + BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics ) { LLVector3 ray_start_region; @@ -200,13 +214,13 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics ) case LL_PCODE_LEGACY_GRASS: // Randomize size of grass patch scale.setVec(10.f + ll_frand(20.f), 10.f + ll_frand(20.f), 1.f + ll_frand(2.f)); - state = rand() % LLVOGrass::sMaxGrassSpecies; + state = getTreeGrassSpecies(LLVOGrass::sSpeciesNames, "LastGrass", LLVOGrass::sMaxGrassSpecies); break; case LL_PCODE_LEGACY_TREE: case LL_PCODE_TREE_NEW: - state = rand() % LLVOTree::sMaxTreeSpecies; + state = getTreeGrassSpecies(LLVOTree::sSpeciesNames, "LastTree", LLVOTree::sMaxTreeSpecies); break; case LL_PCODE_SPHERE: diff --git a/linden/indra/newview/llvograss.cpp b/linden/indra/newview/llvograss.cpp index 4e7816c..79addbb 100644 --- a/linden/indra/newview/llvograss.cpp +++ b/linden/indra/newview/llvograss.cpp @@ -71,6 +71,8 @@ F32 w_mod[GRASS_MAX_BLADES]; // Factor to modulate wind movement by to rand LLVOGrass::SpeciesMap LLVOGrass::sSpeciesTable; S32 LLVOGrass::sMaxGrassSpecies = 0; +LLVOGrass::SpeciesNames LLVOGrass::sSpeciesNames; + LLVOGrass::LLVOGrass(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : LLAlphaObject(id, pcode, regionp) @@ -201,11 +203,16 @@ void LLVOGrass::initClass() if (species >= sMaxGrassSpecies) sMaxGrassSpecies = species + 1; + std::string name; + static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); + success &= grass_def->getFastAttributeString(name_string, name); + sSpeciesNames[name] = species; + if (!success) { - std::string name; + /*std::string name; static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); - grass_def->getFastAttributeString(name_string, name); + grass_def->getFastAttributeString(name_string, name);*/ llwarns << "Incomplete definition of grass " << name << llendl; } } diff --git a/linden/indra/newview/llvograss.h b/linden/indra/newview/llvograss.h index 95197a5..de700bd 100644 --- a/linden/indra/newview/llvograss.h +++ b/linden/indra/newview/llvograss.h @@ -116,6 +116,9 @@ public: F32 mBladeWindAngle; F32 mBWAOverlap; + typedef std::map SpeciesNames; + static SpeciesNames sSpeciesNames; + protected: ~LLVOGrass(); diff --git a/linden/indra/newview/llvotree.cpp b/linden/indra/newview/llvotree.cpp index 23c92ea..e1c3542 100644 --- a/linden/indra/newview/llvotree.cpp +++ b/linden/indra/newview/llvotree.cpp @@ -77,6 +77,9 @@ F32 LLVOTree::sTreeFactor = 1.f; LLVOTree::SpeciesMap LLVOTree::sSpeciesTable; S32 LLVOTree::sMaxTreeSpecies = 0; +LLVOTree::SpeciesNames LLVOTree::sSpeciesNames; + + // Tree variables and functions LLVOTree::LLVOTree(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp): @@ -230,11 +233,16 @@ void LLVOTree::initClass() if (species >= sMaxTreeSpecies) sMaxTreeSpecies = species + 1; + std::string name; + static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); + success &= tree_def->getFastAttributeString(name_string, name); + sSpeciesNames[name] = species; + if (!success) { - std::string name; - static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); - tree_def->getFastAttributeString(name_string, name); + //std::string name; + //static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); + //tree_def->getFastAttributeString(name_string, name); llwarns << "Incomplete definition of tree " << name << llendl; } } diff --git a/linden/indra/newview/llvotree.h b/linden/indra/newview/llvotree.h index f34371e..055cfa3 100644 --- a/linden/indra/newview/llvotree.h +++ b/linden/indra/newview/llvotree.h @@ -120,6 +120,9 @@ public: static F32 sTreeFactor; // Tree level of detail factor + typedef std::map SpeciesNames; + static SpeciesNames sSpeciesNames; + friend class LLDrawPoolTree; protected: LLVector3 mTrunkBend; // Accumulated wind (used for blowing trees) diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml b/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml index eb9b1c6..6fc5374 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml @@ -227,6 +227,9 @@ image_unselected="object_grass.tga" label="" label_selected="" left_delta="23" mouse_opaque="true" name="ToolGrass" scale_image="TRUE" tool_tip="Grass" width="24" /> +