From 23d8fb9750afc158d97fdf51633ed59b1b36f223 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 21:21:04 +0300 Subject: STORM-1305 WIP User water presets now go first in all lists. Besides, removed all cases of direct access to the water presets map in preparation for future lazy loading. --- indra/newview/llenvmanager.cpp | 7 ++--- indra/newview/llfloaterdeleteenvpreset.cpp | 14 +++------- indra/newview/llfloatereditwater.cpp | 23 +++++++++++++--- indra/newview/llfloaterenvironmentsettings.cpp | 20 +++++++++++--- indra/newview/llfloaterregioninfo.cpp | 21 ++++++++++++--- indra/newview/llfloaterwater.cpp | 7 ++--- indra/newview/llwaterparammanager.cpp | 36 +++++++++++++++++++++++++- indra/newview/llwaterparammanager.h | 14 ++++++++-- 8 files changed, 112 insertions(+), 30 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index a9083cf3dc..462e6293a8 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -884,10 +884,11 @@ void LLEnvManagerNew::dumpPresets() { LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; } - const LLWaterParamManager::preset_map_t& water_params_map = LLWaterParamManager::instance().getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + LLWaterParamManager::preset_name_list_t water_presets; + LLWaterParamManager::instance().getPresetNames(water_presets); + for (LLWaterParamManager::preset_name_list_t::const_iterator it = water_presets.begin(); it != water_presets.end(); ++it) { - LL_DEBUGS("Windlight") << " - " << it->first << LL_ENDL; + LL_DEBUGS("Windlight") << " - " << *it << LL_ENDL; } // Dump sky presets. diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp index 56412acc07..0b4104affd 100644 --- a/indra/newview/llfloaterdeleteenvpreset.cpp +++ b/indra/newview/llfloaterdeleteenvpreset.cpp @@ -193,17 +193,11 @@ void LLFloaterDeleteEnvPreset::populateWaterPresetsList() cur_preset = env_mgr.getWaterPresetName(); } - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - const LLWaterParamManager::preset_map_t &water_params_map = water_mgr.getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + LLWaterParamManager::preset_name_list_t presets; + LLWaterParamManager::instance().getUserPresetNames(presets); // list only user presets + for (LLWaterParamManager::preset_name_list_t::const_iterator it = presets.begin(); it != presets.end(); ++it) { - std::string name = it->first; - - // list only user presets - if (water_mgr.isSystemPreset(name)) - { - continue; - } + std::string name = *it; bool enabled = (name != cur_preset); // don't allow deleting current preset mPresetCombo->add(name, ADD_BOTTOM, enabled); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index e8c20f5932..64cfc4054f 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -507,11 +507,26 @@ void LLFloaterEditWater::refreshWaterPresetsList() } #endif - // Add local water presets. - const LLWaterParamManager::preset_map_t &water_params_map = LLWaterParamManager::instance().getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + std::list user_presets, system_presets; + LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + + // Add local user presets first. + for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + const std::string& name = *it; + mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [, ] + } + + if (user_presets.size() > 0) + { + mWaterPresetCombo->addSeparator(); + } + + // Add local system presets. + for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) { - mWaterPresetCombo->add(it->first, LLSD().with(0, it->first).with(1, LLEnvKey::SCOPE_LOCAL)); + const std::string& name = *it; + mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [, ] } mWaterPresetCombo->setLabel(getString("combo_label")); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 8f451d7620..66ca3334dd 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -209,10 +209,24 @@ void LLFloaterEnvironmentSettings::populateWaterPresetsList() { mWaterPresetCombo->removeall(); - const LLWaterParamManager::preset_map_t &water_params_map = LLWaterParamManager::getInstance()->getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + std::list user_presets, system_presets; + LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + + // Add user presets first. + for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mWaterPresetCombo->add(*it); + } + + if (user_presets.size() > 0) + { + mWaterPresetCombo->addSeparator(); + } + + // Add system presets. + for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) { - mWaterPresetCombo->add(it->first); + mWaterPresetCombo->add(*it); } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a7ab75a85e..01070fe3e1 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3417,11 +3417,24 @@ void LLPanelEnvironmentInfo::populateWaterPresetsList() mWaterPresetCombo->addSeparator(); } - // Add local water presets. - const LLWaterParamManager::preset_map_t &water_params_map = LLWaterParamManager::instance().getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + std::list user_presets, system_presets; + LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + + // Add local user presets first. + for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); + } + + if (user_presets.size() > 0) + { + mWaterPresetCombo->addSeparator(); + } + + // Add local system presets. + for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) { - mWaterPresetCombo->add(it->first, LLWLParamKey(it->first, LLEnvKey::SCOPE_LOCAL).toLLSD()); + mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); } // There's no way to select current preset because its name is not stored on server. diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index 30bec8a77a..4d647f30f5 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -90,10 +90,11 @@ BOOL LLFloaterWater::postBuild() if(comboBox != NULL) { - const LLWaterParamManager::preset_map_t& preset_map = LLWaterParamManager::getInstance()->getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = preset_map.begin(); it != preset_map.end(); ++it) + LLWaterParamManager::preset_name_list_t presets; + LLWaterParamManager::instance().getPresetNames(presets); + for (LLWaterParamManager::preset_name_list_t::const_iterator it = presets.begin(); it != presets.end(); ++it) { - comboBox->add(it->first); + comboBox->add(*it); } // set defaults on combo boxes diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 968425a029..475f57cdd4 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -367,12 +367,46 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr return true; } -bool LLWaterParamManager::isSystemPreset(const std::string& preset_name) +bool LLWaterParamManager::isSystemPreset(const std::string& preset_name) const { // *TODO: file system access is excessive here. return gDirUtilp->fileExists(getSysDir() + LLURI::escape(preset_name) + ".xml"); } +void LLWaterParamManager::getPresetNames(preset_name_list_t& presets) const +{ + presets.clear(); + + for (preset_map_t::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) + { + presets.push_back(it->first); + } +} + +void LLWaterParamManager::getPresetNames(preset_name_list_t& user_presets, preset_name_list_t& system_presets) const +{ + user_presets.clear(); + system_presets.clear(); + + for (preset_map_t::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) + { + if (isSystemPreset(it->first)) + { + system_presets.push_back(it->first); + } + else + { + user_presets.push_back(it->first); + } + } +} + +void LLWaterParamManager::getUserPresetNames(preset_name_list_t& user_presets) const +{ + preset_name_list_t dummy; + getPresetNames(user_presets, dummy); +} + boost::signals2::connection LLWaterParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) { return mPresetListChangeSignal.connect(cb); diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index 9325faa021..dc7d41be2a 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -27,7 +27,7 @@ #ifndef LL_WATER_PARAMMANAGER_H #define LL_WATER_PARAMMANAGER_H -#include +#include #include #include "llwaterparamset.h" #include "llviewercamera.h" @@ -216,6 +216,7 @@ class LLWaterParamManager : public LLSingleton { LOG_CLASS(LLWaterParamManager); public: + typedef std::list preset_name_list_t; typedef std::map preset_map_t; typedef boost::signals2::signal preset_list_signal_t; @@ -257,11 +258,20 @@ public: bool removeParamSet(const std::string& name, bool delete_from_disk); /// @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 all named water presets. const preset_map_t& getPresets() const { return mParamList; } + /// @return user and system preset names as a single list + void getPresetNames(preset_name_list_t& presets) const; + + /// @return user and system preset names separately + void getPresetNames(preset_name_list_t& user_presets, preset_name_list_t& system_presets) const; + + /// @return list of user presets names + void getUserPresetNames(preset_name_list_t& user_presets) const; + /// Emitted when a preset gets added or deleted. boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); -- cgit v1.2.3