diff options
author | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-06-10 23:44:13 +0300 |
---|---|---|
committer | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-06-10 23:44:13 +0300 |
commit | 4fd946fa3e5217b8f64e0fcd91d268c7eaf1bbf5 (patch) | |
tree | e5c810ecd44990bce20ff502bce4df08976b80f1 /indra/newview | |
parent | 23d8fb9750afc158d97fdf51633ed59b1b36f223 (diff) |
STORM-1305 WIP User sky presets now go first in all lists.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llenvmanager.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llfloaterdaycycle.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llfloaterdeleteenvpreset.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llfloatereditdaycycle.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llfloatereditsky.cpp | 40 | ||||
-rw-r--r-- | indra/newview/llfloaterenvironmentsettings.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 44 | ||||
-rw-r--r-- | indra/newview/llfloaterwindlight.cpp | 14 | ||||
-rw-r--r-- | indra/newview/llwlanimator.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llwlparammanager.cpp | 47 | ||||
-rw-r--r-- | indra/newview/llwlparammanager.h | 24 |
11 files changed, 196 insertions, 80 deletions
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 462e6293a8..c08ef34685 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -893,13 +893,14 @@ void LLEnvManagerNew::dumpPresets() // Dump sky presets. LL_DEBUGS("Windlight") << "Skies:" << LL_ENDL; - const std::map<LLWLParamKey, LLWLParamSet> &sky_params_map = LLWLParamManager::getInstance()->mParamList; - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + LLWLParamManager::preset_key_list_t sky_preset_keys; + LLWLParamManager::instance().getPresetKeys(sky_preset_keys); + for (LLWLParamManager::preset_key_list_t::const_iterator it = sky_preset_keys.begin(); it != sky_preset_keys.end(); ++it) { - std::string preset_name = it->first.name; + std::string preset_name = it->name; std::string item_title; - if (it->first.scope == LLEnvKey::SCOPE_LOCAL) // local preset + if (it->scope == LLEnvKey::SCOPE_LOCAL) // local preset { item_title = preset_name; } diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index ebf7b98148..9fcfc41f77 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -200,14 +200,15 @@ void LLFloaterDayCycle::refreshPresetsFromParamManager() if(keyCombo != NULL) { - std::map<LLWLParamKey, LLWLParamSet>::iterator mIt = - LLWLParamManager::getInstance()->mParamList.begin(); - for(; mIt != LLWLParamManager::getInstance()->mParamList.end(); mIt++) + LLWLParamManager::preset_key_list_t preset_keys; + LLWLParamManager::instance().getPresetKeys(preset_keys); + for (LLWLParamManager::preset_key_list_t::const_iterator it = preset_keys.begin(); it != preset_keys.end(); ++it) { - if(mIt->first.scope <= sScope) + if (it->scope <= sScope) { - llinfos << "Adding key: " << mIt->first.toString() << llendl; - keyCombo->add(mIt->first.toString(), LLSD(mIt->first.toStringVal())); + const LLWLParamKey& key = *it; + llinfos << "Adding key: " << key.toString() << llendl; + keyCombo->add(key.toString(), LLSD(key.toStringVal())); } } diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp index 0b4104affd..cd9f46e5a2 100644 --- a/indra/newview/llfloaterdeleteenvpreset.cpp +++ b/indra/newview/llfloaterdeleteenvpreset.cpp @@ -219,20 +219,12 @@ void LLFloaterDeleteEnvPreset::populateSkyPresetsList() cur_preset = env_mgr.getSkyPresetName(); } - LLWLParamManager& sky_mgr = LLWLParamManager::instance(); - const std::map<LLWLParamKey, LLWLParamSet> &sky_params_map = sky_mgr.mParamList; - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + LLWLParamManager::preset_name_list_t user_presets; + LLWLParamManager::instance().getUserPresetNames(user_presets); + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) { - const LLWLParamKey& key = it->first; - - // 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); + const std::string& name = *it; + mPresetCombo->add(name, ADD_BOTTOM, /*enabled = */ name != cur_preset); } postPopulate(); diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index 2cbe889322..4f4739384d 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -230,24 +230,41 @@ void LLFloaterEditDayCycle::refreshSkyPresetsList() mSkyPresetsCombo->removeall(); - LLWLParamManager& sky_mgr = LLWLParamManager::instance(); - for (std::map<LLWLParamKey, LLWLParamSet>::iterator it = sky_mgr.mParamList.begin(); - it != sky_mgr.mParamList.end(); ++it) - { - const LLWLParamKey& key = it->first; + LLWLParamManager::preset_name_list_t region_presets; + LLWLParamManager::preset_name_list_t user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - std::string item_title = key.name; - if (key.scope == LLEnvKey::SCOPE_REGION) + if (include_region_skies) + { + // Add region presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) { - if (!include_region_skies) - { - continue; - } + std::string preset_name = *it; + std::string item_title = preset_name + " (" + getRegionName() + ")"; + mSkyPresetsCombo->add(preset_name, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toStringVal()); + } - item_title += " (" + getRegionName() + ")"; + if (!region_presets.empty()) + { + mSkyPresetsCombo->addSeparator(); } + } + + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetsCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); + } + + if (!user_presets.empty()) + { + mSkyPresetsCombo->addSeparator(); + } - mSkyPresetsCombo->add(item_title, LLSD(key.toStringVal())); + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) + { + mSkyPresetsCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); } // set defaults on combo boxes diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 27280565c7..053208202d 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -731,21 +731,37 @@ void LLFloaterEditSky::refreshSkyPresetsList() { mSkyPresetCombo->removeall(); + LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + +#if 0 // Disable editing region skies until the workflow is clear enough. + // Add region presets. std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - const std::map<LLWLParamKey, LLWLParamSet> &sky_params_map = LLWLParamManager::getInstance()->mParamList; - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) { - const LLWLParamKey& key = it->first; - std::string item_title = key.name; - if (key.scope == LLEnvKey::SCOPE_REGION) - { -#if 1 // Disable editing region skies until the workflow is clear enough. - continue; -#else - item_title += " (" + region_name + ")"; + std::string item_title = *it + " (" + region_name + ")"; + mSkyPresetCombo->add(item_title, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toLLSD()); + } + if (region_presets.size() > 0) + { + mSkyPresetCombo->addSeparator(); + } #endif - } - mSkyPresetCombo->add(item_title, key.toLLSD()); + + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); + } + if (user_presets.size() > 0) + { + mSkyPresetCombo->addSeparator(); + } + + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); } mSkyPresetCombo->setLabel(getString("combo_label")); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 66ca3334dd..e8d123a955 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -234,11 +234,25 @@ void LLFloaterEnvironmentSettings::populateSkyPresetsList() { mSkyPresetCombo->removeall(); - const std::map<LLWLParamKey, LLWLParamSet> &sky_params_map = LLWLParamManager::getInstance()->mParamList; - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here + LLWLParamManager::preset_name_list_t user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetCombo->add(*it); + } + + if (!user_presets.empty()) + { + mSkyPresetCombo->addSeparator(); + } + + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) { - if (it->first.scope == LLEnvKey::SCOPE_REGION) continue; // list only local presets - mSkyPresetCombo->add(it->first.name); + mSkyPresetCombo->add(*it); } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 01070fe3e1..3734e5e280 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3444,23 +3444,39 @@ void LLPanelEnvironmentInfo::populateSkyPresetsList() { mSkyPresetCombo->removeall(); - const std::map<LLWLParamKey, LLWLParamSet> &sky_params_map = LLWLParamManager::getInstance()->mParamList; - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + LLWLParamManager::preset_name_list_t region_presets; + LLWLParamManager::preset_name_list_t user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + + // Add region presets. + std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); + for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) { - std::string preset_name = it->first.name; - std::string item_title; + std::string preset_name = *it; + std::string item_title = preset_name + " (" + region_name + ")"; + mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); + } - if (it->first.scope == LLEnvKey::SCOPE_LOCAL) // local preset - { - item_title = preset_name; - } - else // region preset - { - item_title = preset_name + " (" + gAgent.getRegion()->getName() + ")"; - } + if (!region_presets.empty()) + { + mSkyPresetCombo->addSeparator(); + } - // Saving as string instead of LLSD() for selectByValue() to work, as it doesn't support non-scalar values. - mSkyPresetCombo->add(item_title, it->first.toStringVal()); + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); + } + + if (!user_presets.empty()) + { + mSkyPresetCombo->addSeparator(); + } + + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); } // Select current preset. diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index f78fada155..43c61f2994 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -80,16 +80,17 @@ BOOL LLFloaterWindLight::postBuild() if(comboBox != NULL) { - std::map<LLWLParamKey, LLWLParamSet>::iterator mIt = - LLWLParamManager::getInstance()->mParamList.begin(); - for(; mIt != LLWLParamManager::getInstance()->mParamList.end(); mIt++) + LLWLParamManager::preset_key_list_t preset_keys; + LLWLParamManager::instance().getPresetKeys(preset_keys); + for (LLWLParamManager::preset_key_list_t::const_iterator it = preset_keys.begin(); it != preset_keys.end(); ++it) { - const LLWLParamKey& key = mIt->first; + const LLWLParamKey& key = *it; std::string item_title = key.name; if (key.scope == LLEnvKey::SCOPE_REGION) { item_title += std::string(" (") + LLTrans::getString("Region") + std::string(")"); } + comboBox->add(item_title, key.toLLSD()); } @@ -240,11 +241,8 @@ bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& // add the current parameters to the list // see if it's there first - std::map<LLWLParamKey, LLWLParamSet>::iterator mIt = - LLWLParamManager::getInstance()->mParamList.find(newKey); - // if not there, add a new one - if(mIt == LLWLParamManager::getInstance()->mParamList.end()) + if (!LLWLParamManager::instance().hasParamSet(newKey)) { LLWLParamManager::getInstance()->addParamSet(newKey, LLWLParamManager::getInstance()->mCurParams); diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp index 0a3fd3cfee..e568638cf6 100644 --- a/indra/newview/llwlanimator.cpp +++ b/indra/newview/llwlanimator.cpp @@ -123,6 +123,7 @@ void LLWLAnimator::update(LLWLParamSet& curParams) } // determine moving target for final interpolation value + // *TODO: this will not work with lazy loading of sky presets. LLWLParamSet buf = LLWLParamSet(); buf.setAll(LLWLParamManager::getInstance()->mParamList[mFirstIt->second].getAll()); // just give it some values, otherwise it has no params to begin with (see comment in constructor) buf.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); // mix to determine moving target for interpolation finish (as below) @@ -137,6 +138,7 @@ void LLWLAnimator::update(LLWLParamSet& curParams) else { // do the interpolation and set the parameters + // *TODO: this will not work with lazy loading of sky presets. curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); } } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 944773de17..f475b3da01 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -630,12 +630,57 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ mPresetListChangeSignal(); } -bool LLWLParamManager::isSystemPreset(const std::string& preset_name) +bool LLWLParamManager::isSystemPreset(const std::string& preset_name) const { // *TODO: file system access is excessive here. return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); } +void LLWLParamManager::getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const +{ + region.clear(); + user.clear(); + sys.clear(); + + for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) + { + const LLWLParamKey& key = it->first; + const std::string& name = key.name; + + if (key.scope == LLEnvKey::SCOPE_REGION) + { + region.push_back(name); + } + else + { + if (isSystemPreset(name)) + { + sys.push_back(name); + } + else + { + user.push_back(name); + } + } + } +} + +void LLWLParamManager::getUserPresetNames(preset_name_list_t& user) const +{ + preset_name_list_t region, sys; // unused + getPresetNames(region, user, sys); +} + +void LLWLParamManager::getPresetKeys(preset_key_list_t& keys) const +{ + keys.clear(); + + for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) + { + keys.push_back(it->first); + } +} + boost::signals2::connection LLWLParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) { return mPresetListChangeSignal.connect(cb); diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 4a76542b95..bc984b9126 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -27,7 +27,7 @@ #ifndef LL_WLPARAMMANAGER_H #define LL_WLPARAMMANAGER_H -#include <vector> +#include <list> #include <map> #include "llenvmanager.h" #include "llwlparamset.h" @@ -217,6 +217,8 @@ class LLWLParamManager : public LLSingleton<LLWLParamManager> LOG_CLASS(LLWLParamManager); public: + typedef std::list<std::string> preset_name_list_t; + typedef std::list<LLWLParamKey> preset_key_list_t; typedef boost::signals2::signal<void()> preset_list_signal_t; /// save the parameter presets to file @@ -281,7 +283,16 @@ public: void clearParamSetsOfScope(LLEnvKey::EScope scope); /// @return true if the preset comes out of the box - bool isSystemPreset(const std::string& preset_name); + bool isSystemPreset(const std::string& preset_name) const; + + /// @return user and system preset names as a single list + void getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const; + + /// @return user preset names + void getUserPresetNames(preset_name_list_t& user) const; + + /// @return keys of all known presets + void getPresetKeys(preset_key_list_t& keys) const; /// Emitted when a preset gets added or deleted. boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); @@ -353,11 +364,11 @@ public: F32 mDomeOffset; F32 mDomeRadius; - // list of all the parameters, listed by name - std::map<LLWLParamKey, LLWLParamSet> mParamList; - + private: + friend class LLWLAnimator; + void loadAllPresets(); void loadPresetsFromDir(const std::string& dir); bool loadPreset(const std::string& path); @@ -370,6 +381,9 @@ private: LLWLParamManager(); ~LLWLParamManager(); + // list of all the parameters, listed by name + std::map<LLWLParamKey, LLWLParamSet> mParamList; + preset_list_signal_t mPresetListChangeSignal; }; |