Merge back the ability to select the tree (not just random, from Imprudence).

Conflicts:

	indra/newview/app_settings/settings.xml
	indra/newview/llfloatertools.cpp
This commit is contained in:
Siana Gearz
2011-10-04 06:07:52 +02:00
parent 2cba3c45bd
commit 0a9c611dfd
9 changed files with 144 additions and 3 deletions

View File

@@ -14538,5 +14538,27 @@
<key>Value</key>
<integer>1</integer>
</map>
<key>LastGrass</key>
<map>
<key>Comment</key>
<string>The last grass selected in the create dialog</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>Random</string>
</map>
<key>LastTree</key>
<map>
<key>Comment</key>
<string>The last tree selected in the create dialog</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>Random</string>
</map>
</map>
</llsd>

View File

@@ -31,6 +31,7 @@
*/
#include "llviewerprecompiledheaders.h"
indra/newview/llfloatertools.cpp
#include "llfloatertools.h"
@@ -87,6 +88,8 @@
#include "qtoolalign.h" //Thank Qarl!
#include "llvograss.h"
#include "llvotree.h"
// Globals
LLFloaterTools *gFloaterTools = NULL;
@@ -295,6 +298,8 @@ BOOL LLFloaterTools::postBuild()
llwarns << "Tool button not found! DOA Pending." << llendl;
}
}
mComboTreesGrass = getChild<LLComboBox>("trees_grass");
childSetCommitCallback("trees_grass", onSelectTreesGrass, (void*)0);
mCheckCopySelection = getChild<LLCheckBoxCtrl>("checkbox copy selection");
childSetValue("checkbox copy selection",(BOOL)gSavedSettings.getBOOL("CreateToolCopySelection"));
mCheckSticky = getChild<LLCheckBoxCtrl>("checkbox sticky");
@@ -392,6 +397,7 @@ LLFloaterTools::LLFloaterTools()
mBtnDuplicate(NULL),
mBtnDuplicateInPlace(NULL),
mComboTreesGrass(NULL),
mCheckSticky(NULL),
mCheckCopySelection(NULL),
mCheckCopyCenters(NULL),
@@ -721,6 +727,8 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
mBtnCreate ->setToggleState( tool == LLToolCompCreate::getInstance() );
updateTreeGrassCombo(create_visible);
if (mCheckCopySelection
&& mCheckCopySelection->get())
{
@@ -1058,3 +1066,77 @@ void LLFloaterTools::onFocusReceived()
LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
LLFloater::onFocusReceived();
}
// 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);
}
}
void LLFloaterTools::updateTreeGrassCombo(bool visible)
{
LLTextBox* tree_grass_label = getChild<LLTextBox>("tree_grass_label");
if (visible)
{
LLPCode pcode = LLToolPlacer::getObjectType();
std::map<std::string, S32>::iterator it, end;
std::string selected;
if (pcode == LLToolPlacerPanel::sTree)
{
tree_grass_label->setVisible(visible);
LLButton* button = getChild<LLButton>("ToolTree");
tree_grass_label->setText(button->getToolTip());
selected = gSavedSettings.getString("LastTree");
it = LLVOTree::sSpeciesNames.begin();
end = LLVOTree::sSpeciesNames.end();
}
else if (pcode == LLToolPlacerPanel::sGrass)
{
tree_grass_label->setVisible(visible);
LLButton* button = getChild<LLButton>("ToolGrass");
tree_grass_label->setText(button->getToolTip());
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);
mComboTreesGrass->setVisible(false);
tree_grass_label->setVisible(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);
tree_grass_label->setVisible(visible);
}

View File

@@ -155,6 +155,7 @@ public:
LLButton *mBtnDuplicateInPlace;
// Create buttons
LLComboBox *mComboTreesGrass;
LLCheckBoxCtrl *mCheckSticky;
LLCheckBoxCtrl *mCheckCopySelection;
LLCheckBoxCtrl *mCheckCopyCenters;
@@ -194,6 +195,9 @@ private:
BOOL mDirty;
std::map<std::string, std::string> mStatusText;
void updateTreeGrassCombo(bool visible);
static void onSelectTreesGrass(LLUICtrl*, void*);
};
extern LLFloaterTools *gFloaterTools;

View File

@@ -175,7 +175,18 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
return TRUE;
}
S32 LLToolPlacer::getTreeGrassSpecies(std::map<std::string, S32> &table, const char *control, S32 max)
{
const std::string &species = gSavedSettings.getString(control);
std::map<std::string, S32>::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;
@@ -220,13 +231,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:

View File

@@ -62,6 +62,7 @@ protected:
private:
BOOL addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics );
S32 getTreeGrassSpecies(std::map<std::string, S32> &table, const char *control, S32 max);
BOOL raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj, S32* hit_face,
BOOL* b_hit_land, LLVector3* ray_start_region, LLVector3* ray_end_region, LLViewerRegion** region );
BOOL addDuplicate(S32 x, S32 y);

View File

@@ -74,6 +74,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)
@@ -198,6 +200,11 @@ 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;

View File

@@ -117,6 +117,9 @@ public:
F32 mBladeWindAngle;
F32 mBWAOverlap;
typedef std::map<std::string, S32> SpeciesNames;
static SpeciesNames sSpeciesNames;
protected:
~LLVOGrass();

View File

@@ -83,6 +83,8 @@ 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):
@@ -243,6 +245,11 @@ 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;

View File

@@ -153,6 +153,10 @@ public:
};
static F32 sTreeFactor; // Tree level of detail factor
typedef std::map<std::string, S32> SpeciesNames;
static SpeciesNames sSpeciesNames;
static const S32 sMAX_NUM_TREE_LOD_LEVELS ;
friend class LLDrawPoolTree;