summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterdeleteenvpreset.cpp
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2011-06-07 17:41:26 +0300
committerVadim ProductEngine <vsavchuk@productengine.com>2011-06-07 17:41:26 +0300
commit7151a4e6b02f02155387fc595034a42aebd7ec9c (patch)
tree4e8727d56b795edc20d43a70f295ec47b3c937f5 /indra/newview/llfloaterdeleteenvpreset.cpp
parent497c0983bb013cb65b6faf10045ea7b62511cc55 (diff)
STORM-1255 WIP Consistency pass on sky presets removal.
* Update all related floaters when a sky preset gets removed. * Don't allow removing skies referenced by (local) day cycles. * Other minor fixes.
Diffstat (limited to 'indra/newview/llfloaterdeleteenvpreset.cpp')
-rw-r--r--indra/newview/llfloaterdeleteenvpreset.cpp51
1 files changed, 43 insertions, 8 deletions
diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp
index 74c837af53..b78e124e07 100644
--- a/indra/newview/llfloaterdeleteenvpreset.cpp
+++ b/indra/newview/llfloaterdeleteenvpreset.cpp
@@ -62,7 +62,9 @@ BOOL LLFloaterDeleteEnvPreset::postBuild()
getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this));
getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this));
- LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::onDayCycleListChange, this));
+ // Listen to presets addition/removal.
+ LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateDayCyclesList, this));
+ LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateSkyPresetsList, this));
return TRUE;
}
@@ -113,6 +115,13 @@ void LLFloaterDeleteEnvPreset::onBtnDelete()
}
else if (param == "sky")
{
+ // Don't allow deleting presets referenced by local day cycles.
+ if (LLDayCycleManager::instance().isSkyPresetReferenced(preset_name))
+ {
+ LLNotificationsUtil::add("GenericAlert", LLSD().with("MESSAGE", getString("msg_sky_is_referenced")));
+ return;
+ }
+
LLWLParamManager& wl_mgr = LLWLParamManager::instance();
// Don't allow deleting system presets.
@@ -155,6 +164,8 @@ void LLFloaterDeleteEnvPreset::onBtnCancel()
void LLFloaterDeleteEnvPreset::populateWaterPresetsList()
{
+ if (mKey.asString() != "water") return;
+
mPresetCombo->removeall();
// *TODO: Reload the list when user preferences change.
@@ -168,10 +179,14 @@ void LLFloaterDeleteEnvPreset::populateWaterPresetsList()
bool enabled = (name != water_mgr.mCurParams.mName); // don't allow deleting current preset
mPresetCombo->add(name, ADD_BOTTOM, enabled);
}
+
+ postPopulate();
}
void LLFloaterDeleteEnvPreset::populateSkyPresetsList()
{
+ if (mKey.asString() != "sky") return;
+
mPresetCombo->removeall();
std::string cur_preset;
@@ -187,14 +202,24 @@ void LLFloaterDeleteEnvPreset::populateSkyPresetsList()
for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++)
{
const LLWLParamKey& key = it->first;
- if (key.scope == LLEnvKey::SCOPE_REGION) continue; // list only local presets
- bool enabled = key.name != cur_preset && !sky_mgr.isSystemPreset(key.name);
+
+ // list only local user presets
+ if (key.scope == LLEnvKey::SCOPE_REGION || sky_mgr.isSystemPreset(key.name))
+ {
+ continue;
+ }
+
+ bool enabled = (key.name != cur_preset);
mPresetCombo->add(key.name, ADD_BOTTOM, enabled);
}
+
+ postPopulate();
}
void LLFloaterDeleteEnvPreset::populateDayCyclesList()
{
+ if (mKey.asString() != "day_cycle") return;
+
mPresetCombo->removeall();
// *TODO: Disable current day cycle.
@@ -203,6 +228,21 @@ void LLFloaterDeleteEnvPreset::populateDayCyclesList()
{
mPresetCombo->add(it->first);
}
+
+ postPopulate();
+}
+
+void LLFloaterDeleteEnvPreset::postPopulate()
+{
+ // Handle empty list.
+ S32 n_items = mPresetCombo->getItemCount();
+
+ if (n_items == 0)
+ {
+ mPresetCombo->setLabel(getString("combo_label"));
+ }
+
+ getChild<LLButton>("delete")->setEnabled(n_items > 0);
}
void LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation()
@@ -215,8 +255,3 @@ void LLFloaterDeleteEnvPreset::onDeleteSkyPresetConfirmation()
LLWLParamKey key(mPresetCombo->getValue().asString(), LLEnvKey::SCOPE_LOCAL);
LLWLParamManager::instance().removeParamSet(key, true);
}
-
-void LLFloaterDeleteEnvPreset::onDayCycleListChange()
-{
- populateDayCyclesList();
-}