From 435b1ab185f88ec9716e8abfca61e80b2b44fabd Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Sat, 9 Apr 2011 16:34:41 +0200 Subject: add some basic cloud preferences in prefs > advanced >eye candy - please review perms --- linden/indra/newview/app_settings/cloud.xml | 5 +- linden/indra/newview/llappviewer.cpp | 5 ++ linden/indra/newview/llprefsadvanced.cpp | 97 +++++++++++++++++++++- linden/indra/newview/llprefsadvanced.h | 12 ++- linden/indra/newview/llvoavatar.cpp | 40 ++++++++- linden/indra/newview/llvoavatar.h | 7 +- .../default/xui/en-us/panel_particle_settings.xml | 46 ++++++++++ .../xui/en-us/panel_preferences_advanced.xml | 9 ++ 8 files changed, 212 insertions(+), 9 deletions(-) create mode 100644 linden/indra/newview/skins/default/xui/en-us/panel_particle_settings.xml (limited to 'linden') diff --git a/linden/indra/newview/app_settings/cloud.xml b/linden/indra/newview/app_settings/cloud.xml index e62bcf1..fdc420a 100644 --- a/linden/indra/newview/app_settings/cloud.xml +++ b/linden/indra/newview/app_settings/cloud.xml @@ -49,8 +49,9 @@ ParticleMaxAge 4 - PartImageID - 0000000000000-0000-0000-000000000000 + PartImageID + + 0000000000000-0000-0000-000000000000 StartColor diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index 0bb5759..1d62a1a 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -4203,6 +4203,11 @@ void LLAppViewer::disconnectViewer() saveNameCache(); + { + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "cloud.xml"); + LLVOAvatar::saveCloud(filename, LLVOAvatar::sCloud); + } + // close inventory interface, close all windows LLInventoryView::cleanup(); // Don't cleanup menus on disconnect in order to avoid crashes -- MC diff --git a/linden/indra/newview/llprefsadvanced.cpp b/linden/indra/newview/llprefsadvanced.cpp index c3a9c0b..ad60694 100644 --- a/linden/indra/newview/llprefsadvanced.cpp +++ b/linden/indra/newview/llprefsadvanced.cpp @@ -42,8 +42,9 @@ #include "lggautocorrectfloater.h" #include "llcombobox.h" #include "llcolorswatch.h" - +#include "llstartup.h" #include "lluictrlfactory.h" +#include "lltexturectrl.h" #include "boost/algorithm/string.hpp" @@ -116,9 +117,12 @@ BOOL LLPrefsAdvanced::postBuild() getChild("EmSpell_Remove")->setClickedCallback(onSpellRemove, this); getChild("ac_button")->setClickedCallback(onAutoCorrectButton,this); - initHelpBtn("EmeraldHelp_SpellCheck", "EmeraldHelp_SpellCheck"); + + getChild("save_cloud_this_account")->setClickedCallback(onSaveThisCloudButton,this); + getChild("save_cloud_any_account")->setClickedCallback(onSaveAnyoneCloudButton,this); + refresh(); return TRUE; @@ -144,6 +148,8 @@ void LLPrefsAdvanced::apply() gSavedSettings.setU32("LightShareAllowed", (U32)childGetValue("lightshare_combo").asInteger()); + + // Need to force a rebake when ClothingLayerProtection toggled for it take effect -- MC if (gSavedSettings.getBOOL("ShowMyClientTagToOthers") != (BOOL)childGetValue("client_name_tag_broadcast_check")) { @@ -208,11 +214,17 @@ void LLPrefsAdvanced::apply() LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, crash_behavior_combobox->getCurrentIndex()); + + onSaveThisCloudButton(NULL); } void LLPrefsAdvanced::cancel() { gSavedSettings.setColor4("ImprudenceTagColor", mClientTagColor); +// llwarns << "cancel" << llendl; +// cool - "ok" is also cancel +// LLVOAvatar::sCloud.mPartData.mStartColor = mCloudStartColor; +// LLVOAvatar::sCloud.mPartData.mEndColor = mCloudEndColor; } void LLPrefsAdvanced::refresh() @@ -272,6 +284,74 @@ void LLPrefsAdvanced::refresh() } comboBox->selectByValue(selected); } + + + bool is_logged_in = LLStartUp::isLoggedIn(); + setParticleControls(is_logged_in); + +} + +void LLPrefsAdvanced::draw() +{ + + bool is_logged_in = LLStartUp::isLoggedIn(); + if(LLVOAvatar::sHasCloud && mWasLoggedIn != is_logged_in) + { + + + setParticleControls(is_logged_in); + + mCloudStartColor = LLVOAvatar::sCloud.mPartData.mStartColor; + mCloudEndColor = LLVOAvatar::sCloud.mPartData.mEndColor; + + + getChild("part_start_color_swatch")->set(mCloudStartColor); + getChild("part_end_color_swatch")->set(mCloudEndColor); + + + mCloudTextureID = LLVOAvatar::sCloud.mPartImageID; + LLTextureCtrl* texture_ctrl = getChild("part_texture_picker"); + if (texture_ctrl) + { + texture_ctrl->setImageAssetID(mCloudTextureID); + texture_ctrl->setAllowNoTexture( true ); + + // Don't allow (no copy) or (no transfer) textures to be selected. + // With that we are less permissive than the original LL code of + // LLWaterParamManager, which allows picking (and saving) plain texture uuids + // without any permission check. + // If real absurdity is necessary we let the user save a windlight water setting + // for the texture uuid. + + texture_ctrl->setImmediateFilterPermMask(PERM_NONE);//PERM_COPY | PERM_TRANSFER); + texture_ctrl->setNonImmediateFilterPermMask(PERM_NONE); + } + + + mWasLoggedIn = is_logged_in; + } + + if(LLVOAvatar::sHasCloud && is_logged_in) + { + + LLVOAvatar::sCloud.mPartData.mStartColor = childGetValue("part_start_color_swatch"); + LLVOAvatar::sCloud.mPartData.mEndColor = childGetValue("part_end_color_swatch"); + LLVOAvatar::sCloud.mPartImageID = childGetValue("part_texture_picker"); + } + + LLPanel::draw(); +} + +void LLPrefsAdvanced::setParticleControls(bool is_logged_in) +{ + + childSetEnabled("save_cloud_this_account", is_logged_in); + childSetEnabled("save_cloud_any_account", is_logged_in); + childSetEnabled("part_start_color_swatch", is_logged_in); + childSetEnabled("part_end_color_swatch", is_logged_in); + childSetEnabled("part_texture_picker", is_logged_in ); + + childSetVisible("must_be_logged_in_textbox", !is_logged_in); } //static @@ -338,3 +418,16 @@ void LLPrefsAdvanced::onClickCommandLine(void* data) FloaterCommandLine::getInstance()->open(); FloaterCommandLine::getInstance()->center(); } + +void LLPrefsAdvanced::onSaveThisCloudButton(void * data) +{ + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "cloud.xml"); + LLVOAvatar::saveCloud(filename, LLVOAvatar::sCloud); +} + +void LLPrefsAdvanced::onSaveAnyoneCloudButton(void * data) +{ + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "cloud.xml"); + LLVOAvatar::saveCloud(filename, LLVOAvatar::sCloud); +} + diff --git a/linden/indra/newview/llprefsadvanced.h b/linden/indra/newview/llprefsadvanced.h index 22236ce..87ddc59 100644 --- a/linden/indra/newview/llprefsadvanced.h +++ b/linden/indra/newview/llprefsadvanced.h @@ -33,6 +33,7 @@ #include "llpanel.h" #include "llviewerinventory.h" +class LLColor4; class LLPrefsAdvanced : public LLPanel { @@ -45,7 +46,7 @@ public: void apply(); void cancel(); void refresh(); - + void draw(); private: static LLPrefsAdvanced* sInstance; @@ -58,12 +59,21 @@ private: static void onSpellEditCustom(void* data); static void onSpellBaseComboBoxCommit(LLUICtrl* ctrl, void* userdata); static void onAutoCorrectButton(void * data); + static void onSaveThisCloudButton(void * data); + static void onSaveAnyoneCloudButton(void * data); LLColor4 mClientTagColor; protected: + void setParticleControls(bool is_logged_in); void initHelpBtn(const std::string& name, const std::string& xml_alert); static void onClickHelp(void* data); + +private: + bool mWasLoggedIn; + LLColor4 mCloudStartColor; + LLColor4 mCloudEndColor; + LLUUID mCloudTextureID; }; #endif // LLPREFSADVANCED_H diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp index 41d1c88..d8b0994 100644 --- a/linden/indra/newview/llvoavatar.cpp +++ b/linden/indra/newview/llvoavatar.cpp @@ -1038,6 +1038,7 @@ LLVOAvatar::~LLVOAvatar() LL_DEBUGS("VOAvatar") << "Destructing Zombie from previous session." << LL_ENDL; } + mRoot.removeAllChildren(); delete [] mSkeleton; @@ -1493,6 +1494,8 @@ void LLVOAvatar::cleanupClass() } LLPartSysData LLVOAvatar::sCloud; +bool LLVOAvatar::sHasCloud = false; + void LLVOAvatar::initCloud() { // fancy particle cloud designed by Brent @@ -1506,12 +1509,43 @@ void LLVOAvatar::initCloud() filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "cloud.xml"); } + loadCloud(filename, sCloud); + sHasCloud = true; +} + + +void LLVOAvatar::loadCloud(const std::string& filename, LLPartSysData& particles) +{ LLSD cloud; llifstream in_file(filename); LLSDSerialize::fromXMLDocument(cloud, in_file); - sCloud.fromLLSD(cloud); - LLViewerImage* cloud_image = gImageList.getImageFromFile("cloud-particle.j2c"); - sCloud.mPartImageID = cloud_image->getID(); + + particles.fromLLSD(cloud); + if(particles.mPartImageID.isNull()) + { + LLViewerImage* cloud_image = gImageList.getImageFromFile("cloud-particle.j2c"); + particles.mPartImageID = cloud_image->getID(); + } +} + + +void LLVOAvatar::saveCloud(const std::string& filename, LLPartSysData& particles) +{ + llofstream out(filename); + if (!out.good()) + { + llwarns << "Unable to open " << filename << " for output." << llendl; + return; + } + LLSDSerialize::toXML(particles.asLLSD(), out); + out.close(); + + // Imprudence: actually we could export any particle system with this, + // though we don't have a clue about its creator (could be from a no mod script) :( + // This is probably also not ok to export on open sim grids, + // unless theiy either add a creator property to particle systems + // or their terms of service make sure this sort of content is free and open. + // Saving only the cloud for now, which only exists client side. } diff --git a/linden/indra/newview/llvoavatar.h b/linden/indra/newview/llvoavatar.h index e585a6a..4d08bf0 100644 --- a/linden/indra/newview/llvoavatar.h +++ b/linden/indra/newview/llvoavatar.h @@ -97,7 +97,11 @@ public: static void initClass(); // Initialize data that's only init'd once per class. static void cleanupClass(); // Cleanup data that's only init'd once per class. static BOOL parseSkeletonFile(const std::string& filename); + static void initCloud(); + static void loadCloud(const std::string& filename, LLPartSysData& particles); + static void saveCloud(const std::string& filename, LLPartSysData& particles); + virtual U32 processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, @@ -587,7 +591,8 @@ public: static F32 sLODFactor; // user-settable LOD factor static BOOL sJointDebug; // output total number of joints being touched for each avatar static BOOL sDebugAvatarRotation; - static LLPartSysData sCloud; + static LLPartSysData sCloud; + static bool sHasCloud; static S32 sNumVisibleAvatars; // Number of instances of this class diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_particle_settings.xml b/linden/indra/newview/skins/default/xui/en-us/panel_particle_settings.xml new file mode 100644 index 0000000..e5064dd --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/panel_particle_settings.xml @@ -0,0 +1,46 @@ + + + + + Start Color: + + + + End Color: + + + + Texture: + + + +