llenvsettings.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /**
  2. * @file llenvsettings.h
  3. * @brief Subclasses for viewer specific settings behaviors.
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2019, Linden Research, Inc.
  8. * Copyright (c) 2019-2023, Henri Beauchamp.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LL_ENVSETTINGS_H
  34. #define LL_ENVSETTINGS_H
  35. #include "llglslshader.h"
  36. #include "llextendedstatus.h"
  37. #include "llsdserialize.h"
  38. #include "llsettingsdaycycle.h"
  39. #include "llsettingssky.h"
  40. #include "llsettingswater.h"
  41. class LLInventoryItem;
  42. class LLEnvSettingsBase : public LLSettingsBase
  43. {
  44. friend class LLSettingsInventoryCB;
  45. protected:
  46. LOG_CLASS(LLEnvSettingsBase);
  47. public:
  48. typedef boost::function<void(LLUUID asset_id,
  49. LLSettingsBase::ptr_t settings, S32 status,
  50. LLExtStat extstat)> asset_download_fn;
  51. typedef boost::function<void(LLUUID asset_id, LLUUID inventory_id,
  52. LLUUID object_id,
  53. LLSD results)> inv_result_fn;
  54. static void createNewInventoryItem(LLSettingsType::EType stype,
  55. const LLUUID& parent_id,
  56. inv_result_fn cb = inv_result_fn());
  57. static void createInventoryItem(const LLSettingsBase::ptr_t& settings,
  58. const LLUUID& parent_id,
  59. const std::string& settings_name,
  60. inv_result_fn cb = inv_result_fn());
  61. static void createInventoryItem(const LLSettingsBase::ptr_t& settings,
  62. U32 next_owner_perm,
  63. const LLUUID& parent_id,
  64. std::string settings_name,
  65. inv_result_fn cb = inv_result_fn());
  66. static void updateInventoryItem(const LLSettingsBase::ptr_t& settings,
  67. const LLUUID& inv_item_id,
  68. inv_result_fn cb = inv_result_fn(),
  69. bool update_name = true);
  70. static void updateInventoryItem(const LLSettingsBase::ptr_t& settings,
  71. const LLUUID& object_id,
  72. const LLUUID& inv_item_id,
  73. inv_result_fn callback = inv_result_fn());
  74. static void getSettingsAsset(const LLUUID& asset_id, asset_download_fn cb);
  75. static bool exportFile(const LLSettingsBase::ptr_t& settings,
  76. const std::string& filename,
  77. LLSDSerialize::ELLSD_Serialize format =
  78. LLSDSerialize::LLSD_NOTATION);
  79. static LLSettingsBase::ptr_t importFile(const std::string& filename);
  80. static LLSettingsBase::ptr_t createFromLLSD(const LLSD& settings);
  81. static LLSD readLegacyPresetData(std::string filename, std::string path,
  82. LLSD& messages);
  83. private:
  84. LLEnvSettingsBase() {}
  85. struct SettingsSaveData
  86. {
  87. typedef std::shared_ptr<SettingsSaveData> ptr_t;
  88. LLSettingsBase::ptr_t mSettings;
  89. LLTransactionID mTransId;
  90. std::string mType;
  91. std::string mTempFile;
  92. };
  93. static void onInventoryItemCreated(const LLUUID& inv_id,
  94. LLSettingsBase::ptr_t settings,
  95. inv_result_fn cb);
  96. static void onAgentAssetUploadComplete(LLUUID item_id, LLUUID new_asset_id,
  97. LLUUID new_item_id, LLSD response,
  98. LLSettingsBase::ptr_t psettings,
  99. inv_result_fn cb);
  100. static void onTaskAssetUploadComplete(LLUUID item_id, LLUUID task_id,
  101. LLUUID new_asset_id, LLSD response,
  102. LLSettingsBase::ptr_t psettings,
  103. inv_result_fn cb);
  104. static void onAssetDownloadComplete(const LLUUID& asset_id,
  105. LLAssetType::EType, void* user_data,
  106. S32 status, LLExtStat ext_status);
  107. };
  108. class LLEnvSettingsSky : public LLSettingsSky
  109. {
  110. protected:
  111. LOG_CLASS(LLEnvSettingsSky);
  112. LLEnvSettingsSky();
  113. void updateSettings() override;
  114. void applySpecial(LLShaderUniforms* targetp) override;
  115. const parammapping_t& getParameterMap() const override;
  116. public:
  117. LLEnvSettingsSky(const LLSD& data, bool advanced = false);
  118. ptr_t buildClone() const override;
  119. LL_INLINE bool isAdvanced() const { return mIsAdvanced; }
  120. static ptr_t buildSky(LLSD settings);
  121. static ptr_t buildFromLegacyPreset(const std::string& name,
  122. const LLSD& old_settings,
  123. LLSD& messages);
  124. static ptr_t buildDefaultSky();
  125. static ptr_t buildFromLegacyPresetFile(const std::string& name,
  126. const std::string& filename,
  127. const std::string& path,
  128. LLSD& messages);
  129. static bool applyPresetByName(std::string name, bool ignore_case = false);
  130. protected:
  131. F32 mSceneLightStrength;
  132. bool mIsAdvanced;
  133. };
  134. class LLEnvSettingsWater : public LLSettingsWater
  135. {
  136. protected:
  137. LOG_CLASS(LLEnvSettingsWater);
  138. LLEnvSettingsWater();
  139. void updateSettings() override;
  140. void applySpecial(LLShaderUniforms* targetp) override;
  141. const parammapping_t& getParameterMap() const override;
  142. public:
  143. LLEnvSettingsWater(const LLSD& data);
  144. ptr_t buildClone() const override;
  145. static ptr_t buildWater(LLSD settings);
  146. static ptr_t buildFromLegacyPreset(const std::string& name,
  147. const LLSD& old_settings,
  148. LLSD& messages);
  149. static ptr_t buildDefaultWater();
  150. static ptr_t buildFromLegacyPresetFile(const std::string& name,
  151. const std::string& filename,
  152. const std::string& path,
  153. LLSD& messages);
  154. static bool applyPresetByName(std::string name, bool ignore_case = false);
  155. };
  156. class LLEnvSettingsDay : public LLSettingsDay
  157. {
  158. protected:
  159. LOG_CLASS(LLEnvSettingsDay);
  160. LLEnvSettingsDay();
  161. public:
  162. typedef boost::function<void(LLSettingsDay::ptr_t day)> asset_built_fn;
  163. LLEnvSettingsDay(const LLSD& data);
  164. ptr_t buildClone() const override;
  165. ptr_t buildDeepCloneAndUncompress() const override;
  166. LLSettingsSky::ptr_t getDefaultSky() const override;
  167. LLSettingsWater::ptr_t getDefaultWater() const override;
  168. LLSettingsSky::ptr_t buildSky(const LLSD& settings) const override;
  169. LLSettingsWater::ptr_t buildWater(const LLSD& settings) const override;
  170. static ptr_t buildDay(LLSD settings);
  171. static ptr_t buildFromLegacyPreset(const std::string& name,
  172. const std::string& path,
  173. const LLSD& old_settings,
  174. LLSD& messages);
  175. static ptr_t buildFromLegacyPresetFile(const std::string& name,
  176. const std::string& filename,
  177. const std::string& path,
  178. LLSD& messages);
  179. static ptr_t buildFromLegacyMessage(const LLUUID& region_id,
  180. LLSD daycycle, LLSD skys, LLSD water);
  181. static ptr_t buildDefaultDayCycle();
  182. static ptr_t buildFromEnvironmentMessage(LLSD settings);
  183. static void buildFromOtherSetting(LLSettingsBase::ptr_t settings,
  184. asset_built_fn cb);
  185. static bool applyPresetByName(std::string name, bool ignore_case = false);
  186. private:
  187. static void combineIntoDayCycle(LLSettingsDay::ptr_t day,
  188. LLSettingsBase::ptr_t settings,
  189. asset_built_fn cb);
  190. };
  191. #endif // LL_ENVSETTINGS_H