Feature Request: Post Process Effects from Quick Settings flyout

Adds a neat little signal for post process to fire when effects change
Isn't code wonderful?
This commit is contained in:
Lirusaito
2019-02-25 12:50:08 -05:00
parent f4a22ef857
commit 46dff21e97
7 changed files with 44 additions and 56 deletions

View File

@@ -675,10 +675,11 @@ void LLPostProcess::setSelectedEffect(std::string const & effectName)
{
mSelectedEffectName = effectName;
mSelectedEffectInfo = mAllEffectInfo[effectName];
for(std::list<LLPointer<LLPostProcessShader> >::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;

View File

@@ -34,6 +34,7 @@
#define LL_POSTPROCESS_H
#include <map>
#include <boost/signals2.hpp>
#include "llsd.h"
#include "llrendertarget.h"
@@ -103,6 +104,9 @@ private:
// The map of all availible effects
LLSD mAllEffectInfo;
typedef boost::signals2::signal<void(const std::string&)> 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);
};

View File

@@ -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<LLUICtrl>("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<LLComboBox>("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<LLComboBox>("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;i<it->second.size();++i)
{
childSetValue(it->first+"["+boost::lexical_cast<std::string>(i)+"]",it->second[i]);
childSetValue(it->first+'['+boost::lexical_cast<std::string>(i)+']',it->second[i]);
}
}
else

View File

@@ -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<LLFloaterPostProcess>
{
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;

View File

@@ -193,7 +193,6 @@ struct MenuFloaterDict : public LLSingleton<MenuFloaterDict>
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<LLFloaterRegionDebugConsole>, (void*)NULL), boost::bind(LLFloaterRegionDebugConsole::instanceExists));
@@ -237,6 +236,7 @@ struct MenuFloaterDict : public LLSingleton<MenuFloaterDict>
registerFloater<LLFloaterPathfindingCharacters> ("pathfinding_characters");
registerFloater<LLFloaterPathfindingLinksets> ("pathfinding_linksets");
registerFloater<LLFloaterPermsDefault> ("perm prefs");
registerFloater<LLFloaterPostProcess> ("PostProcess");
registerFloater<LLFloaterAvatarList> ("radar");
registerFloater<ALFloaterRegionTracker> ("region_tracker");
registerFloater<LLFloaterScriptLimits> ("script info");

View File

@@ -16,6 +16,10 @@
<slider bottom_delta="-20" control_name="RenderMaxPartCount" decimal_digits="0" height="20" increment="256" label="Particles:" can_edit_text="true" label_width="60" max_val="8192" min_val="0" val_width="36" name="MaxParticleCount" width="190" tool_tip="Amount of particles to render"/>
<slider bottom_delta="-20" control_name="RenderAvatarMaxVisible" decimal_digits="0" height="20" increment="1" label="Max Avs:" can_edit_text="true" label_width="60" max_val="50" min_val="1" val_width="36" name="RenderAvatarMaxVisible" width="190" tool_tip="How many avatars to fully render on screen. Lowering this greatly improves FPS in crowded situations. Requires Avatar Impostors to be on. [Default 35]"/>
<slider bottom_delta="-20" control_name="RenderVolumeLODFactor" height="20" increment="0.125" label="Obj. Detail:" can_edit_text="true" label_width="60" max_val="4" min_val="0.5" name="Object Detail" val_width="36" width="190" tool_tip="Controls level of detail of primitives (multiplier for current screen area when calculated level of detail[0.5 to 2.0 is stable])"/>
<button bottom_delta="-22" left="5" height="20" name="PostProcessButton" width="20" image_overlay="Inv_Post_Process.png" label="" tool_tip="Post Process Effects"/>
<combo_box name="PostProcessPresetsCombo" bottom_delta="1" left_delta="20" height="18" width="131" tool_tip="Post Process Presets"/>
<button bottom_delta="-1" height="19" label="&lt;" left="157" image_overlay="arrow_left.tga" name="PPprev" scale_image="true" width="19"/>
<button bottom_delta="0" height="19" label="&gt;" left_delta="18" image_overlay="arrow_right.tga" name="PPnext" width="19"/>
<button bottom_delta="-22" left="5" height="20" name="EnvAdvancedSkyButton" width="20" image_overlay="Inv_WindLight.png" label="" tool_tip="Advanced Sky"/>
<combo_box name="WLSkyPresetsCombo" bottom_delta="1" left_delta="20" height="18" width="131" tool_tip="WindLight Presets for your Sky."/>
<button bottom_delta="-1" height="19" label="&lt;" left="157" image_overlay="arrow_left.tga" name="WLprev" scale_image="true" width="19"/>

View File

@@ -40,6 +40,7 @@
#include "llsliderctrl.h"
#include "lluictrlfactory.h"
#include "llfloaterpostprocess.h"
#include "llfloaterwindlight.h"
#include "llfloaterwater.h"
@@ -152,6 +153,9 @@ BOOL wlfPanel_AdvSettings::postBuild()
// Windlight
getChild<LLCheckBoxCtrl>("use_estate_wl")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onUseRegionSettings, this, _2));
auto mPostProcessPresetCombo = getChild<LLComboBox>("PostProcessPresetsCombo");
mPostProcessPresetCombo->setCommitCallback(boost::bind(&LLPostProcess::setSelectedEffect, LLPostProcess::getInstance(), boost::bind(&LLSD::asStringRef, _2)));
mWaterPresetCombo = getChild<LLComboBox>("WLWaterPresetsCombo");
mWaterPresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeWWPresetName, this, _2));
@@ -161,21 +165,27 @@ BOOL wlfPanel_AdvSettings::postBuild()
// mDayCyclePresetCombo = getChild<LLComboBox>("DCPresetsCombo");
// mDayCyclePresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeDCPresetName, this, _2));
void populatePostProcessList(LLComboBox* comboBox);
mConnections.push_front(new boost::signals2::scoped_connection(LLPostProcess::instance().setSelectedEffectChangeCallback(boost::bind(populatePostProcessList, mPostProcessPresetCombo))));
mConnections.push_front(new boost::signals2::scoped_connection(LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&wlfPanel_AdvSettings::refreshLists, this))));
mConnections.push_front(new boost::signals2::scoped_connection(LLWaterParamManager::getInstance()->setPresetListChangeCallback(boost::bind(&wlfPanel_AdvSettings::populateWaterPresetsList, this))));
mConnections.push_front(new boost::signals2::scoped_connection(LLWLParamManager::getInstance()->setPresetListChangeCallback(boost::bind(&wlfPanel_AdvSettings::populateSkyPresetsList, this))));
// LLDayCycleManager::instance().setModifyCallback(boost::bind(&wlfPanel_AdvSettings::populateDayCyclePresetsList, this));
populatePostProcessList(mPostProcessPresetCombo);
populateWaterPresetsList();
populateSkyPresetsList();
//populateDayCyclePresetsList();
// next/prev buttons
getChild<LLUICtrl>("PPnext")->setCommitCallback(boost::bind(wlfPanel_AdvSettings::onClickArrow, mPostProcessPresetCombo, true));
getChild<LLUICtrl>("PPprev")->setCommitCallback(boost::bind(wlfPanel_AdvSettings::onClickArrow, mPostProcessPresetCombo, false));
getChild<LLUICtrl>("WWnext")->setCommitCallback(boost::bind(wlfPanel_AdvSettings::onClickArrow, mWaterPresetCombo, true));
getChild<LLUICtrl>("WWprev")->setCommitCallback(boost::bind(wlfPanel_AdvSettings::onClickArrow, mWaterPresetCombo, false));
getChild<LLUICtrl>("WLnext")->setCommitCallback(boost::bind(wlfPanel_AdvSettings::onClickArrow, mSkyPresetCombo, true));
getChild<LLUICtrl>("WLprev")->setCommitCallback(boost::bind(wlfPanel_AdvSettings::onClickArrow, mSkyPresetCombo, false));
getChild<LLUICtrl>("PostProcessButton")->setCommitCallback(boost::bind(LLFloaterPostProcess::toggleInstance, LLSD()));
getChild<LLUICtrl>("EnvAdvancedSkyButton")->setCommitCallback(boost::bind(LLFloaterWindLight::show));
getChild<LLUICtrl>("EnvAdvancedWaterButton")->setCommitCallback(boost::bind(LLFloaterWater::show));