llfloaterpostprocess.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:9k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llfloaterpostprocess.cpp
  3.  * @brief LLFloaterPostProcess class definition
  4.  *
  5.  * $LicenseInfo:firstyear=2007&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2007-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llfloaterpostprocess.h"
  34. #include "llsliderctrl.h"
  35. #include "llcheckboxctrl.h"
  36. #include "llnotificationsutil.h"
  37. #include "lluictrlfactory.h"
  38. #include "llviewerdisplay.h"
  39. #include "llpostprocess.h"
  40. #include "llcombobox.h"
  41. #include "lllineeditor.h"
  42. #include "llviewerwindow.h"
  43. LLFloaterPostProcess::LLFloaterPostProcess(const LLSD& key)
  44.   : LLFloater(key)
  45. {
  46. //LLUICtrlFactory::getInstance()->buildFloater(this, "floater_post_process.xml");
  47. }
  48. LLFloaterPostProcess::~LLFloaterPostProcess()
  49. {
  50. }
  51. BOOL LLFloaterPostProcess::postBuild()
  52. {
  53. /// Color Filter Callbacks
  54. childSetCommitCallback("ColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter");
  55. //childSetCommitCallback("ColorFilterGamma", &LLFloaterPostProcess::onFloatControlMoved, &(gPostProcess->tweaks.gamma()));
  56. childSetCommitCallback("ColorFilterBrightness", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness");
  57. childSetCommitCallback("ColorFilterSaturation", &LLFloaterPostProcess::onFloatControlMoved, (char*)"saturation");
  58. childSetCommitCallback("ColorFilterContrast", &LLFloaterPostProcess::onFloatControlMoved, (char*)"contrast");
  59. childSetCommitCallback("ColorFilterBaseR", &LLFloaterPostProcess::onColorControlRMoved, (char*)"contrast_base");
  60. childSetCommitCallback("ColorFilterBaseG", &LLFloaterPostProcess::onColorControlGMoved, (char*)"contrast_base");
  61. childSetCommitCallback("ColorFilterBaseB", &LLFloaterPostProcess::onColorControlBMoved, (char*)"contrast_base");
  62. childSetCommitCallback("ColorFilterBaseI", &LLFloaterPostProcess::onColorControlIMoved, (char*)"contrast_base");
  63. /// Night Vision Callbacks
  64. childSetCommitCallback("NightVisionToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_night_vision");
  65. childSetCommitCallback("NightVisionBrightMult", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness_multiplier");
  66. childSetCommitCallback("NightVisionNoiseSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_size");
  67. childSetCommitCallback("NightVisionNoiseStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_strength");
  68. /// Bloom Callbacks
  69. childSetCommitCallback("BloomToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_bloom");
  70. childSetCommitCallback("BloomExtract", &LLFloaterPostProcess::onFloatControlMoved, (char*)"extract_low");
  71. childSetCommitCallback("BloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width");
  72. childSetCommitCallback("BloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength");
  73. // Effect loading and saving.
  74. LLComboBox* comboBox = getChild<LLComboBox>("PPEffectsCombo");
  75. getChild<LLComboBox>("PPLoadEffect")->setCommitCallback(boost::bind(&LLFloaterPostProcess::onLoadEffect, this, comboBox));
  76. comboBox->setCommitCallback(boost::bind(&LLFloaterPostProcess::onChangeEffectName, this, _1));
  77. LLLineEditor* editBox = getChild<LLLineEditor>("PPEffectNameEditor");
  78. getChild<LLComboBox>("PPSaveEffect")->setCommitCallback(boost::bind(&LLFloaterPostProcess::onSaveEffect, this, editBox));
  79. syncMenu();
  80. return TRUE;
  81. }
  82. // Bool Toggle
  83. void LLFloaterPostProcess::onBoolToggle(LLUICtrl* ctrl, void* userData)
  84. {
  85. char const * boolVariableName = (char const *)userData;
  86. // check the bool
  87. LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
  88. gPostProcess->tweaks[boolVariableName] = cbCtrl->getValue();
  89. }
  90. // Float Moved
  91. void LLFloaterPostProcess::onFloatControlMoved(LLUICtrl* ctrl, void* userData)
  92. {
  93. char const * floatVariableName = (char const *)userData;
  94. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  95. gPostProcess->tweaks[floatVariableName] = sldrCtrl->getValue();
  96. }
  97. // Color Moved
  98. void LLFloaterPostProcess::onColorControlRMoved(LLUICtrl* ctrl, void* userData)
  99. {
  100. char const * floatVariableName = (char const *)userData;
  101. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  102. gPostProcess->tweaks[floatVariableName][0] = sldrCtrl->getValue();
  103. }
  104. // Color Moved
  105. void LLFloaterPostProcess::onColorControlGMoved(LLUICtrl* ctrl, void* userData)
  106. {
  107. char const * floatVariableName = (char const *)userData;
  108. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  109. gPostProcess->tweaks[floatVariableName][1] = sldrCtrl->getValue();
  110. }
  111. // Color Moved
  112. void LLFloaterPostProcess::onColorControlBMoved(LLUICtrl* ctrl, void* userData)
  113. {
  114. char const * floatVariableName = (char const *)userData;
  115. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  116. gPostProcess->tweaks[floatVariableName][2] = sldrCtrl->getValue();
  117. }
  118. // Color Moved
  119. void LLFloaterPostProcess::onColorControlIMoved(LLUICtrl* ctrl, void* userData)
  120. {
  121. char const * floatVariableName = (char const *)userData;
  122. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  123. gPostProcess->tweaks[floatVariableName][3] = sldrCtrl->getValue();
  124. }
  125. void LLFloaterPostProcess::onLoadEffect(LLComboBox* comboBox)
  126. {
  127. LLSD::String effectName(comboBox->getSelectedValue().asString());
  128. gPostProcess->setSelectedEffect(effectName);
  129. syncMenu();
  130. }
  131. void LLFloaterPostProcess::onSaveEffect(LLLineEditor* editBox)
  132. {
  133. std::string effectName(editBox->getValue().asString());
  134. if (gPostProcess->mAllEffects.has(effectName))
  135. {
  136. LLSD payload;
  137. payload["effect_name"] = effectName;
  138. LLNotificationsUtil::add("PPSaveEffectAlert", LLSD(), payload, boost::bind(&LLFloaterPostProcess::saveAlertCallback, this, _1, _2));
  139. }
  140. else
  141. {
  142. gPostProcess->saveEffect(effectName);
  143. syncMenu();
  144. }
  145. }
  146. void LLFloaterPostProcess::onChangeEffectName(LLUICtrl* ctrl)
  147. {
  148. // get the combo box and name
  149. LLLineEditor* editBox = getChild<LLLineEditor>("PPEffectNameEditor");
  150. // set the parameter's new name
  151. editBox->setValue(ctrl->getValue());
  152. }
  153. bool LLFloaterPostProcess::saveAlertCallback(const LLSD& notification, const LLSD& response)
  154. {
  155. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  156. // if they choose save, do it.  Otherwise, don't do anything
  157. if (option == 0)
  158. {
  159. gPostProcess->saveEffect(notification["payload"]["effect_name"].asString());
  160. syncMenu();
  161. }
  162. return false;
  163. }
  164. void LLFloaterPostProcess::syncMenu()
  165. {
  166. // add the combo boxe contents
  167. LLComboBox* comboBox = getChild<LLComboBox>("PPEffectsCombo");
  168. comboBox->removeall();
  169. LLSD::map_const_iterator currEffect;
  170. for(currEffect = gPostProcess->mAllEffects.beginMap();
  171. currEffect != gPostProcess->mAllEffects.endMap();
  172. ++currEffect) 
  173. {
  174. comboBox->add(currEffect->first);
  175. }
  176. // set the current effect as selected.
  177. comboBox->selectByValue(gPostProcess->getSelectedEffect());
  178. /// Sync Color Filter Menu
  179. childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter());
  180. //childSetValue("ColorFilterGamma", gPostProcess->tweaks.gamma());
  181. childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness());
  182. childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation());
  183. childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast());
  184. childSetValue("ColorFilterBaseR", gPostProcess->tweaks.contrastBaseR());
  185. childSetValue("ColorFilterBaseG", gPostProcess->tweaks.contrastBaseG());
  186. childSetValue("ColorFilterBaseB", gPostProcess->tweaks.contrastBaseB());
  187. childSetValue("ColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity());
  188. /// Sync Night Vision Menu
  189. childSetValue("NightVisionToggle", gPostProcess->tweaks.useNightVisionShader());
  190. childSetValue("NightVisionBrightMult", gPostProcess->tweaks.brightMult());
  191. childSetValue("NightVisionNoiseSize", gPostProcess->tweaks.noiseSize());
  192. childSetValue("NightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength());
  193. /// Sync Bloom Menu
  194. childSetValue("BloomToggle", LLSD(gPostProcess->tweaks.useBloomShader()));
  195. childSetValue("BloomExtract", gPostProcess->tweaks.extractLow());
  196. childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth());
  197. childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength());
  198. }