00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llfloaterpostprocess.h"
00035
00036 #include "llsliderctrl.h"
00037 #include "llcheckboxctrl.h"
00038 #include "lluictrlfactory.h"
00039 #include "llviewerdisplay.h"
00040 #include "llpostprocess.h"
00041 #include "llcombobox.h"
00042 #include "lllineeditor.h"
00043 #include "llviewerwindow.h"
00044
00045
00046 LLFloaterPostProcess* LLFloaterPostProcess::sPostProcess = NULL;
00047
00048
00049 LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater("Post-Process Floater")
00050 {
00051 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_post_process.xml");
00052
00054 childSetCommitCallback("ColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter");
00055
00056 childSetCommitCallback("ColorFilterBrightness", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness");
00057 childSetCommitCallback("ColorFilterSaturation", &LLFloaterPostProcess::onFloatControlMoved, (char*)"saturation");
00058 childSetCommitCallback("ColorFilterContrast", &LLFloaterPostProcess::onFloatControlMoved, (char*)"contrast");
00059
00060 childSetCommitCallback("ColorFilterBaseR", &LLFloaterPostProcess::onColorControlRMoved, (char*)"contrast_base");
00061 childSetCommitCallback("ColorFilterBaseG", &LLFloaterPostProcess::onColorControlGMoved, (char*)"contrast_base");
00062 childSetCommitCallback("ColorFilterBaseB", &LLFloaterPostProcess::onColorControlBMoved, (char*)"contrast_base");
00063 childSetCommitCallback("ColorFilterBaseI", &LLFloaterPostProcess::onColorControlIMoved, (char*)"contrast_base");
00064
00066 childSetCommitCallback("NightVisionToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_night_vision");
00067 childSetCommitCallback("NightVisionBrightMult", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness_multiplier");
00068 childSetCommitCallback("NightVisionNoiseSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_size");
00069 childSetCommitCallback("NightVisionNoiseStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_strength");
00070
00072 childSetCommitCallback("BloomToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_bloom");
00073 childSetCommitCallback("BloomExtract", &LLFloaterPostProcess::onFloatControlMoved, (char*)"extract_low");
00074 childSetCommitCallback("BloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width");
00075 childSetCommitCallback("BloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength");
00076
00077
00078 LLComboBox* comboBox = getChild<LLComboBox>("PPEffectsCombo");
00079 childSetAction("PPLoadEffect", &LLFloaterPostProcess::onLoadEffect, comboBox);
00080 comboBox->setCommitCallback(onChangeEffectName);
00081
00082 LLLineEditor* editBox = getChild<LLLineEditor>("PPEffectNameEditor");
00083 childSetAction("PPSaveEffect", &LLFloaterPostProcess::onSaveEffect, editBox);
00084
00085 syncMenu();
00086
00087 }
00088
00089 LLFloaterPostProcess::~LLFloaterPostProcess()
00090 {
00091
00092
00093 }
00094
00095 LLFloaterPostProcess* LLFloaterPostProcess::instance()
00096 {
00097
00098 if (!sPostProcess)
00099 {
00100 sPostProcess = new LLFloaterPostProcess();
00101 sPostProcess->open();
00102 sPostProcess->setFocus(TRUE);
00103 }
00104 return sPostProcess;
00105 }
00106
00107
00108 void LLFloaterPostProcess::onBoolToggle(LLUICtrl* ctrl, void* userData)
00109 {
00110 char const * boolVariableName = (char const *)userData;
00111
00112
00113 LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
00114 gPostProcess->tweaks[boolVariableName] = cbCtrl->getValue();
00115 }
00116
00117
00118 void LLFloaterPostProcess::onFloatControlMoved(LLUICtrl* ctrl, void* userData)
00119 {
00120 char const * floatVariableName = (char const *)userData;
00121 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00122 gPostProcess->tweaks[floatVariableName] = sldrCtrl->getValue();
00123 }
00124
00125
00126 void LLFloaterPostProcess::onColorControlRMoved(LLUICtrl* ctrl, void* userData)
00127 {
00128 char const * floatVariableName = (char const *)userData;
00129 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00130 gPostProcess->tweaks[floatVariableName][0] = sldrCtrl->getValue();
00131 }
00132
00133
00134 void LLFloaterPostProcess::onColorControlGMoved(LLUICtrl* ctrl, void* userData)
00135 {
00136 char const * floatVariableName = (char const *)userData;
00137 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00138 gPostProcess->tweaks[floatVariableName][1] = sldrCtrl->getValue();
00139 }
00140
00141
00142 void LLFloaterPostProcess::onColorControlBMoved(LLUICtrl* ctrl, void* userData)
00143 {
00144 char const * floatVariableName = (char const *)userData;
00145 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00146 gPostProcess->tweaks[floatVariableName][2] = sldrCtrl->getValue();
00147 }
00148
00149
00150 void LLFloaterPostProcess::onColorControlIMoved(LLUICtrl* ctrl, void* userData)
00151 {
00152 char const * floatVariableName = (char const *)userData;
00153 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00154 gPostProcess->tweaks[floatVariableName][3] = sldrCtrl->getValue();
00155 }
00156
00157 void LLFloaterPostProcess::onLoadEffect(void* userData)
00158 {
00159 LLComboBox* comboBox = static_cast<LLComboBox*>(userData);
00160
00161 LLSD::String effectName(comboBox->getSelectedValue().asString());
00162
00163 gPostProcess->setSelectedEffect(effectName);
00164
00165 sPostProcess->syncMenu();
00166 }
00167
00168 void LLFloaterPostProcess::onSaveEffect(void* userData)
00169 {
00170 LLLineEditor* editBox = static_cast<LLLineEditor*>(userData);
00171
00172 LLSD::String effectName(editBox->getValue().asString());
00173
00174 if (gPostProcess->mAllEffects.has(effectName))
00175 {
00176 gViewerWindow->alertXml("PPSaveEffectAlert", &LLFloaterPostProcess::saveAlertCallback, userData);
00177 }
00178 else
00179 {
00180 gPostProcess->saveEffect(effectName);
00181 sPostProcess->syncMenu();
00182 }
00183 }
00184
00185 void LLFloaterPostProcess::onChangeEffectName(LLUICtrl* ctrl, void * userData)
00186 {
00187
00188 LLComboBox * comboBox = static_cast<LLComboBox*>(ctrl);
00189 LLLineEditor* editBox = sPostProcess->getChild<LLLineEditor>("PPEffectNameEditor");
00190
00191
00192 editBox->setValue(comboBox->getSelectedValue());
00193 }
00194
00195 void LLFloaterPostProcess::saveAlertCallback(S32 option, void* userData)
00196 {
00197 LLLineEditor* editBox = static_cast<LLLineEditor*>(userData);
00198
00199
00200 if (option == 0)
00201 {
00202 LLSD::String effectName(editBox->getValue().asString());
00203
00204 gPostProcess->saveEffect(effectName);
00205
00206 sPostProcess->syncMenu();
00207 }
00208
00209 }
00210
00211 void LLFloaterPostProcess::show()
00212 {
00213
00214
00215 LLFloaterPostProcess* postProcess = instance();
00216 postProcess->syncMenu();
00217 postProcess->open();
00218 }
00219
00220
00221 void LLFloaterPostProcess::onClose(bool app_quitting)
00222 {
00223
00224 if (sPostProcess)
00225 {
00226 sPostProcess->setVisible(FALSE);
00227 }
00228 }
00229
00230 void LLFloaterPostProcess::syncMenu()
00231 {
00232
00233 LLComboBox* comboBox = getChild<LLComboBox>("PPEffectsCombo");
00234
00235 comboBox->removeall();
00236
00237 LLSD::map_const_iterator currEffect;
00238 for(currEffect = gPostProcess->mAllEffects.beginMap();
00239 currEffect != gPostProcess->mAllEffects.endMap();
00240 ++currEffect)
00241 {
00242 comboBox->add(currEffect->first);
00243 }
00244
00245
00246 comboBox->selectByValue(gPostProcess->getSelectedEffect());
00247
00249 childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter());
00250
00251 childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness());
00252 childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation());
00253 childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast());
00254 childSetValue("ColorFilterBaseR", gPostProcess->tweaks.contrastBaseR());
00255 childSetValue("ColorFilterBaseG", gPostProcess->tweaks.contrastBaseG());
00256 childSetValue("ColorFilterBaseB", gPostProcess->tweaks.contrastBaseB());
00257 childSetValue("ColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity());
00258
00260 childSetValue("NightVisionToggle", gPostProcess->tweaks.useNightVisionShader());
00261 childSetValue("NightVisionBrightMult", gPostProcess->tweaks.brightMult());
00262 childSetValue("NightVisionNoiseSize", gPostProcess->tweaks.noiseSize());
00263 childSetValue("NightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength());
00264
00266 childSetValue("BloomToggle", LLSD(gPostProcess->tweaks.useBloomShader()));
00267 childSetValue("BloomExtract", gPostProcess->tweaks.extractLow());
00268 childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth());
00269 childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength());
00270 }