diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 9c65dffb4..57541f54e 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -675,10 +675,11 @@ void LLPostProcess::setSelectedEffect(std::string const & effectName) { mSelectedEffectName = effectName; mSelectedEffectInfo = mAllEffectInfo[effectName]; - for(std::list >::iterator it=mShaders.begin();it!=mShaders.end();++it) + for(auto shader : mShaders) { - (*it)->loadSettings(mSelectedEffectInfo); + shader->loadSettings(mSelectedEffectInfo); } + mSelectedEffectChanged(mSelectedEffectName); } void LLPostProcess::setSelectedEffectValue(std::string const & setting, LLSD value) @@ -714,6 +715,7 @@ void LLPostProcess::resetSelectedEffect() void LLPostProcess::saveEffectAs(std::string const & effectName) { mAllEffectInfo[effectName] = mSelectedEffectInfo; + mSelectedEffectChanged(mSelectedEffectName); // Might've changed, either way update the lists std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); //LL_INFOS() << "Saving PostProcess Effects settings to " << pathName << LL_ENDL; diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index 57bd58ef0..a835c9192 100644 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h @@ -34,6 +34,7 @@ #define LL_POSTPROCESS_H #include +#include #include "llsd.h" #include "llrendertarget.h" @@ -103,6 +104,9 @@ private: // The map of all availible effects LLSD mAllEffectInfo; + typedef boost::signals2::signal selected_effect_changed_signal; + selected_effect_changed_signal mSelectedEffectChanged; + public: LLPostProcess(void); ~LLPostProcess(void); @@ -144,6 +148,7 @@ public: // Setters void setSelectedEffect(std::string const & effectName); void setSelectedEffectValue(std::string const & setting, LLSD value); + auto setSelectedEffectChangeCallback(const selected_effect_changed_signal::slot_type& func) { return mSelectedEffectChanged.connect(func); } void resetSelectedEffect(); void saveEffectAs(std::string const & effectName); }; diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp index 22a89e015..70c374d8e 100644 --- a/indra/newview/llfloaterpostprocess.cpp +++ b/indra/newview/llfloaterpostprocess.cpp @@ -52,7 +52,7 @@ LLFloaterPostProcess* LLFloaterPostProcess::sPostProcess = NULL; -LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Process Floater")) +LLFloaterPostProcess::LLFloaterPostProcess(const LLSD&) : LLFloater("Post-Process Floater") { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_post_process.xml"); @@ -91,24 +91,11 @@ LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Proce getChild("PPSaveEffect")->setCommitCallback(boost::bind(&LLFloaterPostProcess::onSaveEffect, this, editBox)); syncMenu(); + LLPostProcess::instance().setSelectedEffectChangeCallback(boost::bind(&LLFloaterPostProcess::syncMenu, this)); } LLFloaterPostProcess::~LLFloaterPostProcess() { - - -} - -LLFloaterPostProcess* LLFloaterPostProcess::instance() -{ - // if we don't have our singleton instance, create it - if (!sPostProcess) - { - sPostProcess = new LLFloaterPostProcess(); - sPostProcess->open(); - sPostProcess->setFocus(TRUE); - } - return sPostProcess; } @@ -122,8 +109,6 @@ void LLFloaterPostProcess::onLoadEffect(LLComboBox* comboBox) LLSD::String effectName(comboBox->getSelectedValue().asString()); LLPostProcess::getInstance()->setSelectedEffect(effectName); - - syncMenu(); } void LLFloaterPostProcess::onSaveEffect(LLLineEditor* editBox) @@ -139,7 +124,6 @@ void LLFloaterPostProcess::onSaveEffect(LLLineEditor* editBox) else { LLPostProcess::getInstance()->saveEffectAs(effectName); - syncMenu(); } } @@ -161,48 +145,40 @@ bool LLFloaterPostProcess::saveAlertCallback(const LLSD& notification, const LLS if (option == 0) { LLPostProcess::getInstance()->saveEffectAs(notification["payload"]["effect_name"].asString()); - - syncMenu(); } return false; } -void LLFloaterPostProcess::show() -{ - // get the instance, make sure the values are synced - // and open the menu - LLFloaterPostProcess* postProcess = instance(); - postProcess->syncMenu(); - postProcess->open(); -} - // virtual void LLFloaterPostProcess::onClose(bool app_quitting) { // just set visibility to false, don't get fancy yet - if (sPostProcess) - { - sPostProcess->setVisible(FALSE); - } + if (app_quitting) + die(); + else + setVisible(FALSE); } -void LLFloaterPostProcess::syncMenu() +void populatePostProcessList(LLComboBox* comboBox) { - // add the combo boxe contents - LLComboBox* comboBox = getChild("PPEffectsCombo"); - comboBox->removeall(); - LLSD::map_const_iterator currEffect; - for(currEffect = LLPostProcess::getInstance()->getAllEffectInfo().beginMap(); - currEffect != LLPostProcess::getInstance()->getAllEffectInfo().endMap(); + const auto& inst(LLPostProcess::instance()); + for(auto currEffect = inst.getAllEffectInfo().beginMap(), end = inst.getAllEffectInfo().endMap(); + currEffect != end; ++currEffect) { comboBox->add(currEffect->first); } // set the current effect as selected. - comboBox->selectByValue(LLPostProcess::getInstance()->getSelectedEffectName()); + comboBox->selectByValue(inst.getSelectedEffectName()); +} + +void LLFloaterPostProcess::syncMenu() +{ + // add the combo boxe contents + populatePostProcessList(getChild("PPEffectsCombo")); const LLSD &tweaks = LLPostProcess::getInstance()->getSelectedEffectInfo(); //Iterate down all uniforms handled by post-process shaders. Update any linked ui elements. @@ -214,7 +190,7 @@ void LLFloaterPostProcess::syncMenu() //llsd["uniform"][1]=>"uniform[1]" for(S32 i=0;isecond.size();++i) { - childSetValue(it->first+"["+boost::lexical_cast(i)+"]",it->second[i]); + childSetValue(it->first+'['+boost::lexical_cast(i)+']',it->second[i]); } } else diff --git a/indra/newview/llfloaterpostprocess.h b/indra/newview/llfloaterpostprocess.h index f49a33981..e2ffbf86e 100644 --- a/indra/newview/llfloaterpostprocess.h +++ b/indra/newview/llfloaterpostprocess.h @@ -49,16 +49,13 @@ class LLPanelFace; /** * Menu for adjusting the post process settings of the world */ -class LLFloaterPostProcess : public LLFloater +class LLFloaterPostProcess : public LLFloater, public LLFloaterSingleton { public: - LLFloaterPostProcess(); + LLFloaterPostProcess(const LLSD&); virtual ~LLFloaterPostProcess(); - /// one and one instance only - static LLFloaterPostProcess* instance(); - /// post process callbacks static void onControlChanged(LLUICtrl* ctrl, const LLSD& v); void onLoadEffect(LLComboBox* comboBox); @@ -68,18 +65,12 @@ public: /// prompts a user when overwriting an effect bool saveAlertCallback(const LLSD& notification, const LLSD& response); - /// show off our menu - static void show(); - /// stuff to do on exit virtual void onClose(bool app_quitting); /// sync up sliders void syncMenu(); -/* - void refresh(); -*/ public: static LLFloaterPostProcess* sPostProcess; diff --git a/indra/newview/llmenucommands.cpp b/indra/newview/llmenucommands.cpp index 56ae324ea..8bed5f4c1 100644 --- a/indra/newview/llmenucommands.cpp +++ b/indra/newview/llmenucommands.cpp @@ -193,7 +193,6 @@ struct MenuFloaterDict : public LLSingleton registerFloater("mouselook", boost::bind(toggle_mouselook)); registerFloater("my land", boost::bind(LLFloaterLandHoldings::show, (void*)NULL)); registerFloater("outfit", boost::bind(show_outfit_dialog)); - registerFloater("PostProcess", boost::bind(LLFloaterPostProcess::show)); registerFloater("preferences", boost::bind(LLFloaterPreference::show, (void*)NULL)); registerFloater("quit", boost::bind(&LLAppViewer::userQuit, LLAppViewer::instance())); registerFloater("RegionDebugConsole", boost::bind(handle_singleton_toggle, (void*)NULL), boost::bind(LLFloaterRegionDebugConsole::instanceExists)); @@ -237,6 +236,7 @@ struct MenuFloaterDict : public LLSingleton registerFloater ("pathfinding_characters"); registerFloater ("pathfinding_linksets"); registerFloater ("perm prefs"); + registerFloater ("PostProcess"); registerFloater ("radar"); registerFloater ("region_tracker"); registerFloater ("script info"); diff --git a/indra/newview/skins/default/xui/en-us/wlfPanel_AdvSettings_expanded.xml b/indra/newview/skins/default/xui/en-us/wlfPanel_AdvSettings_expanded.xml index 053146f3c..4dcb1392c 100644 --- a/indra/newview/skins/default/xui/en-us/wlfPanel_AdvSettings_expanded.xml +++ b/indra/newview/skins/default/xui/en-us/wlfPanel_AdvSettings_expanded.xml @@ -16,6 +16,10 @@ +