hbfloatereditenvsettings.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. * @file hbfloatereditenvsettings.h
  3. * @brief Environment settings editor floater class definition
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2019-2023 Henri Beauchamp
  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. #ifndef LL_HBFLOATEREDITENVSETTINGS_H
  33. #define LL_HBFLOATEREDITENVSETTINGS_H
  34. #include "llfloater.h"
  35. #include "llenvironment.h"
  36. class LLButton;
  37. class LLCheckBoxCtrl;
  38. class LLFlyoutButton;
  39. class LLLineEditor;
  40. class LLPanelEnvSettings;
  41. class LLSliderCtrl;
  42. class LLViewerInventoryItem;
  43. class HBFloaterEditEnvSettings final : public LLFloater
  44. {
  45. friend class HBSettingsCopiedCallback;
  46. protected:
  47. LOG_CLASS(HBFloaterEditEnvSettings);
  48. // Do not call directly: use the static, show() or create() methods instead
  49. HBFloaterEditEnvSettings(const LLUUID& inv_id, LLSettingsType::EType type);
  50. public:
  51. ~HBFloaterEditEnvSettings() override;
  52. void refresh() override;
  53. bool isDirty() const override;
  54. void setDirty(bool dirty = true);
  55. void setEditSettings(const LLSettingsBase::ptr_t& settings);
  56. LL_INLINE const LLUUID& getInventoryId() const { return mInventoryId; }
  57. LL_INLINE LLSettingsType::EType getType() const { return mSettingsType; }
  58. void setSettings(const LLSettingsBase::ptr_t& settings);
  59. void importFromFile(const std::string& filename);
  60. void loadInventoryItem(LLUUID inv_id,
  61. const std::string& notify = LLStringUtil::null);
  62. // Can be used to load the default settings asset for the appropriate
  63. // settings type, when no inventory item has been loaded so far. Used when
  64. // the editor is opened for importing legacy Windlight settings or when
  65. // editing empty environments for regions or parcels.
  66. void loadDefaultSettings();
  67. void setEditContextInventory();
  68. void setEditContextParcel();
  69. void setEditContextRegion();
  70. void setDayLength(S32 seconds);
  71. typedef boost::signals2::signal<void(LLSettingsBase::ptr_t)> commit_signal_t;
  72. typedef commit_signal_t::slot_type commit_cb_t;
  73. typedef boost::signals2::connection connection_t;
  74. connection_t setCommitCB(commit_cb_t cb);
  75. // For editing inventory settings items
  76. static HBFloaterEditEnvSettings* show(LLUUID inv_id);
  77. // For importing legacy Windlight seetings from XML files
  78. static HBFloaterEditEnvSettings* create(LLSettingsType::EType type);
  79. // For closing any edit floater of destroyed inventory item.
  80. static void destroy(const LLUUID& inv_id);
  81. protected:
  82. bool postBuild() override;
  83. void draw() override;
  84. void onClose(bool app_quitting) override;
  85. void onFocusReceived() override;
  86. void onAssetLoaded(const LLUUID& asset_id, LLSettingsBase::ptr_t settings,
  87. S32 status);
  88. void updateEditEnvironment();
  89. void doApplyCreateNewInventory(const std::string& settings_name,
  90. const LLSettingsBase::ptr_t& settings);
  91. void onInventoryCreated(const LLUUID& inv_id, bool copied = false);
  92. void onInventoryCreated(const LLUUID& inv_id, const LLSD& results);
  93. void doApplyUpdateInventory(const LLSettingsBase::ptr_t& settings);
  94. void onInventoryUpdated(const LLUUID& inv_id);
  95. private:
  96. static void* createSettingsPanel(void* userdata);
  97. static void onButtonLoad(void* userdata);
  98. static void onButtonImport(void* userdata);
  99. static void onButtonCancel(void* userdata);
  100. static void onButtonSave(void* userdata);
  101. static void onButtonSaveAsNew(void* userdata);
  102. static void onButtonApply(LLUICtrl* ctrl, void* userdata);
  103. static void onNameChanged(LLUICtrl*, void* userdata);
  104. private:
  105. LLButton* mLoadBtn;
  106. LLButton* mImportBtn;
  107. LLButton* mCancelBtn;
  108. LLButton* mSaveBtn;
  109. LLButton* mSaveAsNewBtn;
  110. LLFlyoutButton* mApplyBtn;
  111. LLLineEditor* mNameEditor;
  112. LLPanelEnvSettings* mEditPanel;
  113. LLViewerInventoryItem* mInventoryItem;
  114. LLUUID mInventoryId;
  115. LLSettingsType::EType mSettingsType;
  116. // Used for the "save as new" feature
  117. U32 mSaveAsNewCounter;
  118. std::string mOriginalName;
  119. commit_signal_t mCommitSignal;
  120. bool mCanSave;
  121. bool mCanCopy;
  122. bool mCanModify;
  123. bool mCanTransfer;
  124. typedef fast_hmap<LLUUID, HBFloaterEditEnvSettings*> instances_map_t;
  125. static instances_map_t sInstances;
  126. };
  127. class HBFloaterLocalEnv final : public LLFloater,
  128. public LLFloaterSingleton<HBFloaterLocalEnv>
  129. {
  130. friend class LLUISingleton<HBFloaterLocalEnv,
  131. VisibilityPolicy<LLFloater> >;
  132. protected:
  133. LOG_CLASS(HBFloaterLocalEnv);
  134. public:
  135. static void closeInstance();
  136. private:
  137. // Open only via LLFloaterSingleton interface, i.e. showInstance() or
  138. // toggleInstance().
  139. HBFloaterLocalEnv(const LLSD&);
  140. bool postBuild() override;
  141. void refresh() override;
  142. //MK
  143. void draw() override;
  144. //mk
  145. void onClose(bool app_quitting) override;
  146. void captureCurrentEnvironment();
  147. static void* createSkySettingsPanel(void* userdata);
  148. static void* createWaterSettingsPanel(void* userdata);
  149. static void onCheckFixedTime(LLUICtrl*, void* userdata);
  150. static void onCommitFixedTime(LLUICtrl*, void* userdata);
  151. static void onButtonReset(void* userdata);
  152. static void onButtonClose(void* userdata);
  153. private:
  154. LLButton* mResetBtn;
  155. LLCheckBoxCtrl* mFixedTimeCheck;
  156. LLSliderCtrl* mFixedTimeSlider;
  157. LLPanelEnvSettings* mEditSkyPanel;
  158. LLPanelEnvSettings* mEditWaterPanel;
  159. LLSettingsSky::ptr_t mLiveSky;
  160. LLSettingsWater::ptr_t mLiveWater;
  161. LLEnvironment::connection_t mEventConnection;
  162. };
  163. #endif // LL_HBFLOATEREDITENVSETTINGS_H