From e045d212d35354d679c2d2e05c6d4689f9f8ac95 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Mon, 27 Sep 2010 22:56:08 -0400 Subject: STORM-1126 WIP Windlight Estate Settings port from 1.23: first pass at merging in windlight estate settings to viewer-dev codebase. not built, not tested. Probably needs a bunch of fixes to be able to be integrated. (resubmitted by Vadim ProductEngine) --- indra/newview/CMakeLists.txt | 21 + indra/newview/app_settings/settings.xml | 11 + indra/newview/featuretable.txt | 2 +- indra/newview/featuretable_linux.txt | 2 +- indra/newview/featuretable_mac.txt | 2 +- indra/newview/llagent.cpp | 19 + indra/newview/lldrawpoolwlsky.cpp | 8 +- indra/newview/llenvmanager.cpp | 474 +++++++++++++++ indra/newview/llenvmanager.h | 214 +++++++ indra/newview/llfloaterdaycycle.cpp | 436 +++++++++----- indra/newview/llfloaterdaycycle.h | 117 ++-- indra/newview/llfloaterenvsettings.cpp | 353 +++++++---- indra/newview/llfloaterenvsettings.h | 93 ++- indra/newview/llfloaterregioninfo.cpp | 148 ++++- indra/newview/llfloaterregioninfo.h | 35 +- indra/newview/llfloaterwater.cpp | 80 +-- indra/newview/llfloaterwater.h | 2 + indra/newview/llfloaterwindlight.cpp | 697 +++++++++++++--------- indra/newview/llfloaterwindlight.h | 113 ++-- indra/newview/llstartup.cpp | 2 - indra/newview/llviewerdisplay.cpp | 4 +- indra/newview/llviewermenu.cpp | 47 +- indra/newview/llviewerregion.cpp | 6 + indra/newview/llviewerregion.h | 5 + indra/newview/llviewershadermgr.cpp | 14 +- indra/newview/llviewershadermgr.h | 16 +- indra/newview/llvosky.cpp | 42 +- indra/newview/llvowlsky.cpp | 4 +- indra/newview/llwaterparammanager.cpp | 33 +- indra/newview/llwaterparammanager.h | 19 +- indra/newview/llwaterparamset.cpp | 43 ++ indra/newview/llwlanimator.cpp | 200 ++++++- indra/newview/llwlanimator.h | 86 ++- indra/newview/llwldaycycle.cpp | 210 ++++--- indra/newview/llwldaycycle.h | 38 +- indra/newview/llwlhandlers.cpp | 159 +++++ indra/newview/llwlhandlers.h | 89 +++ indra/newview/llwlparammanager.cpp | 441 +++++++++----- indra/newview/llwlparammanager.h | 189 ++++-- indra/newview/llwlparamset.cpp | 59 +- indra/newview/llwlparamset.h | 2 +- indra/newview/tests/lldir_stub.cpp | 45 ++ indra/newview/tests/llfloaterdaycycle_stub.cpp | 20 + indra/newview/tests/llfloaterenvsettings_stub.cpp | 20 + indra/newview/tests/llfloaterwindlight_stub.cpp | 20 + indra/newview/tests/llglslshader_stub.cpp | 22 + indra/newview/tests/llpipeline_stub.cpp | 15 + indra/newview/tests/llsky_stub.cpp | 20 + indra/newview/tests/llviewershadermgr_stub.cpp | 33 + indra/newview/tests/llwlanimator_stub.cpp | 12 + indra/newview/tests/llwldaycycle_stub.cpp | 35 ++ indra/newview/tests/llwlparammanager_test.cpp | 257 ++++++++ indra/newview/tests/llwlparamset_stub.cpp | 24 + 53 files changed, 3854 insertions(+), 1204 deletions(-) create mode 100644 indra/newview/llenvmanager.cpp create mode 100644 indra/newview/llenvmanager.h create mode 100644 indra/newview/llwlhandlers.cpp create mode 100644 indra/newview/llwlhandlers.h create mode 100644 indra/newview/tests/lldir_stub.cpp create mode 100644 indra/newview/tests/llfloaterdaycycle_stub.cpp create mode 100644 indra/newview/tests/llfloaterenvsettings_stub.cpp create mode 100644 indra/newview/tests/llfloaterwindlight_stub.cpp create mode 100644 indra/newview/tests/llglslshader_stub.cpp create mode 100644 indra/newview/tests/llpipeline_stub.cpp create mode 100644 indra/newview/tests/llsky_stub.cpp create mode 100644 indra/newview/tests/llviewershadermgr_stub.cpp create mode 100644 indra/newview/tests/llwlanimator_stub.cpp create mode 100644 indra/newview/tests/llwldaycycle_stub.cpp create mode 100644 indra/newview/tests/llwlparammanager_test.cpp create mode 100644 indra/newview/tests/llwlparamset_stub.cpp (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 1f4302d870..533eea7420 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -139,6 +139,7 @@ set(viewer_SOURCE_FILES lldrawpoolwlsky.cpp lldriverparam.cpp lldynamictexture.cpp + llenvmanager.cpp llemote.cpp lleventinfo.cpp lleventnotifier.cpp @@ -562,6 +563,7 @@ set(viewer_SOURCE_FILES llwind.cpp llwlanimator.cpp llwldaycycle.cpp + llwlhandlers.cpp llwlparammanager.cpp llwlparamset.cpp llworld.cpp @@ -670,6 +672,7 @@ set(viewer_HEADER_FILES lldriverparam.h lldynamictexture.h llemote.h + llenvmanager.h lleventinfo.h lleventnotifier.h lleventpoll.h @@ -1088,6 +1091,7 @@ set(viewer_HEADER_FILES llwind.h llwlanimator.h llwldaycycle.h + llwlhandlers.h llwlparammanager.h llwlparamset.h llworld.h @@ -1933,6 +1937,23 @@ if (LL_TESTS) #ADD_VIEWER_BUILD_TEST(lltextureinfodetails viewer) #ADD_VIEWER_BUILD_TEST(lltexturestatsuploader viewer) +include(LLAddBuildTest) +SET(viewer_TEST_SOURCE_FILES + llagentaccess.cpp + llwlparammanager.cpp + # Not *actually* a unit test, it's an integration test. + # Because it won't work in the new unit test iface, i've commented out + # and notified Nat. Delete this when it's replaced! + # + poppy & brad 2009-06-05 + # llcapabilitylistener.cpp + ) +set_source_files_properties( + ${viewer_TEST_SOURCE_FILES} + PROPERTIES + LL_TEST_ADDITIONAL_SOURCE_FILES llviewerprecompiledheaders.cpp + ) +LL_ADD_PROJECT_UNIT_TESTS(${VIEWER_BINARY_NAME} "${viewer_TEST_SOURCE_FILES}") + endif (LL_TESTS) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 742a20a849..d21e978ca5 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11046,6 +11046,17 @@ Value 1 + UseEnvironmentFromRegion + + Comment + Choose whether to use the region's environment settings, or override them with the local settings. + Persist + 1 + Type + Boolean + Value + 0 + UseExternalBrowser Comment diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 721fe81a3c..173e81733c 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 23 +version 24 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt index 1bad7e5260..602f62cf69 100644 --- a/indra/newview/featuretable_linux.txt +++ b/indra/newview/featuretable_linux.txt @@ -1,4 +1,4 @@ -version 22 +version 23 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 4fba47e3df..bbe63be5ae 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 22 +version 23 // NOTE: This is mostly identical to featuretable_mac.txt with a few differences // Should be combined into one table diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index c9bd7851ed..56d2c76dc7 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -36,8 +36,10 @@ #include "llanimationstates.h" #include "llbottomtray.h" #include "llcallingcard.h" +#include "llcapabilitylistener.h" #include "llchannelmanager.h" #include "llconsole.h" +#include "llenvmanager.h" #include "llfirstuse.h" #include "llfloatercamera.h" #include "llfloaterreg.h" @@ -76,6 +78,7 @@ #include "llwindow.h" #include "llworld.h" #include "llworldmap.h" +#include "stringize.h" using namespace LLVOAvatarDefines; @@ -620,6 +623,16 @@ void LLAgent::setRegion(LLViewerRegion *regionp) gSky.mVOGroundp->setRegion(regionp); } + // Notify windlight managers + bool teleport = (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE); + if (teleport) + { + LLEnvManager::getInstance()->notifyTP(); + } + else + { + LLEnvManager::getInstance()->notifyCrossing(); + } } else { @@ -636,6 +649,9 @@ void LLAgent::setRegion(LLViewerRegion *regionp) // Update all of the regions. LLWorld::getInstance()->updateAgentOffset(mAgentOriginGlobal); + + // Notify windlight managers about login + LLEnvManager::getInstance()->notifyLogin(); } } mRegionp = regionp; @@ -653,6 +669,9 @@ void LLAgent::setRegion(LLViewerRegion *regionp) LLSelectMgr::getInstance()->updateSelectionCenter(); LLFloaterMove::sUpdateFlyingStatus(); + + // notify EnvManager that a refresh is needed + LLEnvManager::instance().refreshFromStorage(LLEnvKey::SCOPE_REGION); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 41a299151e..0910d920f2 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -34,6 +34,8 @@ #include "llviewercamera.h" #include "llimage.h" #include "llwlparammanager.h" +#include "llviewershadermgr.h" +#include "llglslshader.h" #include "llsky.h" #include "llvowlsky.h" #include "llviewerregion.h" @@ -66,7 +68,7 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) : sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } LLDrawPoolWLSky::~LLDrawPoolWLSky() @@ -161,7 +163,7 @@ void LLDrawPoolWLSky::renderStars(void) const // clamping and allow the star_alpha param to brighten the stars. bool error; LLColor4 star_alpha(LLColor4::black); - star_alpha.mV[3] = LLWLParamManager::instance()->mCurParams.getFloat("star_brightness", error) / 2.f; + star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f; llassert_always(!error); gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getBloomTex()); @@ -254,7 +256,7 @@ void LLDrawPoolWLSky::render(S32 pass) } LLFastTimer ftm(FTM_RENDER_WL_SKY); - const F32 camHeightLocal = LLWLParamManager::instance()->getDomeOffset() * LLWLParamManager::instance()->getDomeRadius(); + const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); LLGLSNoFog disableFog; LLGLDepthTest depth(GL_TRUE, GL_FALSE); diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp new file mode 100644 index 0000000000..f551aa6c8a --- /dev/null +++ b/indra/newview/llenvmanager.cpp @@ -0,0 +1,474 @@ +/** + * @file llenvmanager.cpp + * @brief Implementation of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llenvmanager.h" + +#include "llagent.h" +#include "llviewerregion.h" + +#include "llfloaterwindlight.h" +#include "llfloaterwater.h" +#include "llfloaterenvsettings.h" +#include "llwlparammanager.h" +#include "llwaterparammanager.h" +#include "llfloaterregioninfo.h" +#include "llwindlightscrubbers.h" +#include "llwlhandlers.h" + +extern LLControlGroup gSavedSettings; + +/*virtual*/ void LLEnvManager::initSingleton() +{ + mOrigSettingStore[LLEnvKey::SCOPE_LOCAL] = lindenDefaults(); + mCurNormalScope = (gSavedSettings.getBOOL("UseEnvironmentFromRegion") ? LLEnvKey::SCOPE_REGION : LLEnvKey::SCOPE_LOCAL); + mInterpNextChangeMessage = true; + mPendingOutgoingMessage = false; + mIsEditing = false; +} + +/******* + * Region Changes + *******/ + +void LLEnvManager::notifyLogin() +{ + changedRegion(false); +} +void LLEnvManager::notifyCrossing() +{ + changedRegion(true); +} +void LLEnvManager::notifyTP() +{ + changedRegion(false); +} +void LLEnvManager::changedRegion(bool interp) +{ + mInterpNextChangeMessage = interp; + mPendingOutgoingMessage = false; + + LLFloaterEnvSettings::instance()->close(); + + resetInternalsToDefault(LLEnvKey::SCOPE_REGION); + + maybeClearEditingScope(LLEnvKey::SCOPE_REGION, true, false); +} + +/******* + * Editing settings / UI mode + *******/ + +void LLEnvManager::startEditingScope(LLEnvKey::EScope scope) +{ + if (mIsEditing) + { + LL_WARNS("Windlight") << "Tried to start editing windlight settings while already editing some settings (possibly others)! Ignoring..." << LL_ENDL; + return; + } + if (!canEdit(scope)) + { + LL_WARNS("Windlight") << "Tried to start editing windlight settings while not allowed to! Ignoring..." << LL_ENDL; + return; + } + + mIsEditing = true; + mCurEditingScope = scope; + + // show scope being edited + loadSettingsIntoManagers(scope, false); + + switch (scope) + { + case LLEnvKey::SCOPE_LOCAL: + // not implemented here (yet) + return; + case LLEnvKey::SCOPE_REGION: + LLPanelRegionTerrainInfo::instance()->setCommitControls(true); + break; + default: + return; + } +} + +void LLEnvManager::maybeClearEditingScope(LLEnvKey::EScope scope, bool user_initiated, bool was_commit) +{ + if (mIsEditing && mCurEditingScope == scope) + { + maybeClearEditingScope(user_initiated, was_commit); // handles UI, updating managers, etc. + } +} + +void LLEnvManager::maybeClearEditingScope(bool user_initiated, bool was_commit) +{ + bool clear_now = true; + if (mIsEditing && !was_commit) + { + if(user_initiated) + { + LLSD args; + args["SCOPE"] = getScopeString(mCurEditingScope); + LLNotifications::instance().add("EnvEditUnsavedChangesCancel", args, LLSD(), + boost::bind(&LLEnvManager::clearEditingScope, this, _1, _2)); + clear_now = false; + } + else + { + LLNotifications::instance().add("EnvEditExternalCancel", LLSD()); + } + } + + if(clear_now) + { + clearEditingScope(LLSD(), LLSD()); + } +} + +void LLEnvManager::clearEditingScope(const LLSD& notification, const LLSD& response) +{ + if(notification.isDefined() && response.isDefined() && LLNotification::getSelectedOption(notification, response) != 0) + { + // *TODO: select terrain panel here + mIsEditing = false; + LLFloaterRegionInfo::showInstance(); + return; + } + + mIsEditing = false; + + updateUIFromEditability(); + LLPanelRegionTerrainInfo::instance()->cancelChanges(); + + loadSettingsIntoManagers(mCurNormalScope, true); +} + +void LLEnvManager::updateUIFromEditability() +{ + // *TODO When the checkbox from LLFloaterEnvSettings is moved elsewhere, opening the local environment settings window should auto-display local settings + // Currently, disable all editing to ensure region settings are hidden from those that can't edit them (to preserve possibility of future tradable assets) + // Remove "!gSavedSettings.getBOOL(...)" when the desired behavior is implemented + LLFloaterEnvSettings::instance()->setControlsEnabled(canEdit(LLEnvKey::SCOPE_LOCAL) && !gSavedSettings.getBOOL("UseEnvironmentFromRegion")); + LLPanelRegionTerrainInfo::instance()->setEnvControls(canEdit(LLEnvKey::SCOPE_REGION)); + // enable estate UI iff canEdit(LLEnvKey::SCOPE_ESTATE), etc. +} + +bool LLEnvManager::regionCapable() +{ + return !gAgent.getRegion()->getCapability("EnvironmentSettings").empty(); +} + +const std::string LLEnvManager::getScopeString(LLEnvKey::EScope scope) +{ + switch(scope) + { + case LLEnvKey::SCOPE_LOCAL: + return LLTrans::getString("LocalSettings"); + case LLEnvKey::SCOPE_REGION: + return LLTrans::getString("RegionSettings"); + default: + return " (?)"; + } +} + +bool LLEnvManager::canEdit(LLEnvKey::EScope scope) +{ + // can't edit while a message is being sent or if already editing + if (mPendingOutgoingMessage || mIsEditing) + { + return false; + } + + // check permissions and caps + switch (scope) + { + case LLEnvKey::SCOPE_LOCAL: + return true; // always permitted to edit local + case LLEnvKey::SCOPE_REGION: + bool owner_or_god_or_manager; + { + LLViewerRegion* region = gAgent.getRegion(); + if (NULL == region || region->getCapability("EnvironmentSettings").empty()) + { + // not a windlight-aware region + return false; + } + owner_or_god_or_manager = gAgent.isGodlike() + || (region && (region->getOwner() == gAgent.getID())) + || (region && region->isEstateManager()); + } + return owner_or_god_or_manager; + default: + return false; + } +} + +/******* + * Incoming Messaging + *******/ + +void LLEnvManager::refreshFromStorage(LLEnvKey::EScope scope) +{ + switch (scope) + { + case LLEnvKey::SCOPE_LOCAL: + break; + case LLEnvKey::SCOPE_REGION: + if (!LLEnvironmentRequestResponder::initiateRequest()) + { + // don't have a cap for this, presume invalid response + processIncomingMessage(LLSD(), scope); + } + break; + default: + processIncomingMessage(LLSD(), scope); + break; + } +} + +bool LLEnvManager::processIncomingMessage(const LLSD& unvalidated_content, const LLEnvKey::EScope scope) +{ + if (scope != LLEnvKey::SCOPE_REGION) + { + return false; + } + + // Start out with defaults + resetInternalsToDefault(scope); + updateUIFromEditability(); + + // Validate + std::set empty_set; + LLWLPacketScrubber scrubber(scope, empty_set); + LLSD windlight_llsd = scrubber.scrub(unvalidated_content); + + bool valid = windlight_llsd.isDefined(); // successful scrub + + mLastReceivedID = unvalidated_content[0]["messageID"].asUUID(); // if the message was valid, grab the UUID from it and save it for next outbound update message + + if (valid) + { + F32 sun_hour = LLPanelRegionTerrainInfo::instance()->getSunHour(); // this slider is kept up to date + LLWLParamManager::getInstance()->addAllSkies(scope, windlight_llsd[2]); + LLEnvironmentSettings newSettings(windlight_llsd[1], windlight_llsd[2], windlight_llsd[3], sun_hour); + mOrigSettingStore[scope] = newSettings; + } + else + { + LL_WARNS("Windlight Sync") << "Failed to parse windlight settings!" << LL_ENDL; + // presume defaults (already reset above) + } + + maybeClearEditingScope(scope, false, false); + + // refresh display with new settings, if applicable + if (mCurNormalScope == scope && !mIsEditing) // if mIsEditing still, must be editing some other scope, so don't load + { + loadSettingsIntoManagers(scope, mInterpNextChangeMessage); + } + + mInterpNextChangeMessage = true; // reset flag + + return valid; +} + + +/******* + * Outgoing Messaging + *******/ + +void LLEnvManager::commitSettings(LLEnvKey::EScope scope) +{ + bool success = true; + switch (scope) + { + case (LLEnvKey::SCOPE_LOCAL): + // not implemented - LLWLParamManager and LLWaterParamManager currently manage local storage themselves + break; + case (LLEnvKey::SCOPE_REGION): + mPendingOutgoingMessage = true; + LLSD metadata(LLSD::emptyMap()); + metadata["regionID"] = gAgent.getRegion()->getRegionID(); + metadata["messageID"] = mLastReceivedID; // add last received update ID to outbound message so simulator can handle concurrent updates + + saveSettingsFromManagers(scope); // save current settings into settings store before grabbing from settings store and sending + success = LLEnvironmentApplyResponder::initiateRequest(makePacket(LLEnvKey::SCOPE_REGION, metadata)); + if(success) + { + // while waiting for the return message, render old settings + // (as of Aug 09, we should get an updated RegionInfo packet, which triggers a re-request of Windlight data, which causes us to show new settings) + loadSettingsIntoManagers(LLEnvKey::SCOPE_REGION, true); + } + break; + } + + if(success) + { + // with mPendingOutgoingMessage = true, nothing is editable + updateUIFromEditability(); + maybeClearEditingScope(true, true); + } + else + { + mPendingOutgoingMessage = false; + } +} + +LLSD LLEnvManager::makePacket(LLEnvKey::EScope scope, const LLSD& metadata) +{ + return mOrigSettingStore[scope].makePacket(metadata); +} + +void LLEnvManager::commitSettingsFinished(LLEnvKey::EScope scope) +{ + mPendingOutgoingMessage = false; + + updateUIFromEditability(); +} + +/******* + * Loading defaults + *******/ + +void LLEnvManager::resetInternalsToDefault(LLEnvKey::EScope scope) +{ + if (LLEnvKey::SCOPE_LOCAL != scope) + { + LLWLParamManager::getInstance()->clearParamSetsOfScope(scope); + } + + mOrigSettingStore[scope] = lindenDefaults(); + LLWLParamManager::getInstance()->mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); +} + +const LLEnvironmentSettings& LLEnvManager::lindenDefaults() +{ + static bool loaded = false; + static LLEnvironmentSettings defSettings; + + if (!loaded) + { + LLWaterParamSet defaultWater; + LLWaterParamManager::instance().getParamSet("default", defaultWater); + + // *TODO save default skies (remove hack in LLWLDayCycle::loadDayCycle when this is done) + + defSettings.saveParams( + LLWLDayCycle::loadCycleDataFromFile("default.xml"), // frames will refer to local presets, which is okay + LLSD(LLSD::emptyMap()), // should never lose the default sky presets (read-only) + defaultWater.getAll(), + 0.0); + + loaded = true; + } + + return defSettings; +} + +/******* + * Manipulation of Param Managers + *******/ + +void LLEnvManager::loadSettingsIntoManagers(LLEnvKey::EScope scope, bool interpolate) +{ + LLEnvironmentSettings settings = mOrigSettingStore[scope]; + + if(interpolate) + { + LLWLParamManager::getInstance()->mAnimator.startInterpolation(settings.getWaterParams()); + } + + LLWLParamManager::getInstance()->addAllSkies(scope, settings.getSkyMap()); + LLWLParamManager::getInstance()->mDay.loadDayCycle(settings.getWLDayCycle(), scope); + LLWLParamManager::getInstance()->resetAnimator(settings.getDayTime(), true); + + LLWaterParamManager::getInstance()->mCurParams.setAll(settings.getWaterParams()); +} + +void LLEnvManager::saveSettingsFromManagers(LLEnvKey::EScope scope) +{ + switch (scope) + { + case LLEnvKey::SCOPE_LOCAL: + mOrigSettingStore[scope].saveParams( + LLWLParamManager::getInstance()->mDay.asLLSD(), + LLSD(LLSD::emptyMap()), // never overwrite + LLWaterParamManager::getInstance()->mCurParams.getAll(), + LLWLParamManager::getInstance()->mAnimator.mDayTime); + break; + case LLEnvKey::SCOPE_REGION: + { + // ensure only referenced region-scope skies are saved, resolve naming collisions, etc. + std::map final_references = LLWLParamManager::getInstance()->finalizeFromDayCycle(scope); + LLSD referenced_skies = LLWLParamManager::getInstance()->createSkyMap(final_references); + mOrigSettingStore[scope].saveParams( + LLWLParamManager::getInstance()->mDay.asLLSD(), + referenced_skies, + LLWaterParamManager::getInstance()->mCurParams.getAll(), + LLWLParamManager::getInstance()->mAnimator.mDayTime); + } + break; + default: + return; + } +} + +/******* + * Setting desired display level + *******/ + +void LLEnvManager::setNormallyDisplayedScope(LLEnvKey::EScope new_scope) +{ + // temp, just save the scope directly as a value in the future when there's more than two + bool want_region = (LLEnvKey::SCOPE_REGION == new_scope); + gSavedSettings.setBOOL("UseEnvironmentFromRegion", want_region); + + if (mCurNormalScope != new_scope) + { + mCurNormalScope = new_scope; + notifyOptInChange(); + } +} + +void LLEnvManager::notifyOptInChange() +{ + bool opt_in = gSavedSettings.getBOOL("UseEnvironmentFromRegion"); + + // Save local settings if switching to region + if(opt_in) + { + LL_INFOS("Windlight") << "Saving currently-displayed settings as current local settings..." << LL_ENDL; + saveSettingsFromManagers(LLEnvKey::SCOPE_LOCAL); + } + + maybeClearEditingScope(true, false); +} diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h new file mode 100644 index 0000000000..1ff4654003 --- /dev/null +++ b/indra/newview/llenvmanager.h @@ -0,0 +1,214 @@ +/** + * @file llenvmanager.h + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLENVMANAGER_H +#define LL_LLENVMANAGER_H + +#include "llmemory.h" +#include "llsd.h" + +class LLWLParamManager; +class LLWaterParamManager; +class LLWLAnimator; + +// generic key +struct LLEnvKey +{ +public: + // Note: enum ordering is important; for example, a region-level floater (1) will see local and region (all values that are <=) + typedef enum e_scope + { + SCOPE_LOCAL, // 0 + SCOPE_REGION//, // 1 + // SCOPE_ESTATE, // 2 + // etc. + } EScope; +}; + +class LLEnvironmentSettings +{ +public: + LLEnvironmentSettings() : + mWLDayCycle(LLSD::emptyMap()), + mSkyMap(LLSD::emptyMap()), + mWaterParams(LLSD::emptyMap()), + mDayTime(0.f) + {} + LLEnvironmentSettings(const LLSD& dayCycle, const LLSD& skyMap, const LLSD& waterParams, F64 dayTime) : + mWLDayCycle(dayCycle), + mSkyMap(skyMap), + mWaterParams(waterParams), + mDayTime(dayTime) + {} + ~LLEnvironmentSettings() {} + + void saveParams(const LLSD& dayCycle, const LLSD& skyMap, const LLSD& waterParams, F64 dayTime) + { + mWLDayCycle = dayCycle; + mSkyMap = skyMap; + mWaterParams = waterParams; + mDayTime = dayTime; + } + + LLSD& getWLDayCycle() + { + return mWLDayCycle; + } + + LLSD& getWaterParams() + { + return mWaterParams; + } + + LLSD& getSkyMap() + { + return mSkyMap; + } + + F64 getDayTime() + { + return mDayTime; + } + + LLSD makePacket(const LLSD& metadata) + { + LLSD full_packet = LLSD::emptyArray(); + + // 0: metadata + full_packet.append(metadata); + + // 1: day cycle + full_packet.append(mWLDayCycle); + + // 2: map of sky setting names to sky settings (as LLSD) + full_packet.append(mSkyMap); + + // 3: water params + full_packet.append(mWaterParams); + + return full_packet; + } + +private: + LLSD mWLDayCycle, mWaterParams, mSkyMap; + F64 mDayTime; +}; + +// not thread-safe +class LLEnvManager : public LLSingleton +{ +public: + // sets scopes (currently, only region-scope) to startup states + // delay calling these until as close as possible to knowing whether the remote service is capable of holding windlight settings + void notifyCrossing(); + // these avoid interpolation on the next incoming message (if it comes) + void notifyLogin(); + void notifyTP(); + + // request settings again from remote storage (currently implemented only for region) + void refreshFromStorage(LLEnvKey::EScope scope); + // stores settings and starts transitions (as necessary) + // validates packet and returns whether it was valid + // loads defaults if not valid + // returns whether or not arguments were valid + bool processIncomingMessage(const LLSD& packet, LLEnvKey::EScope scope); + // saves settings in the given scope to persistent storage appropriate for that scope + void commitSettings(LLEnvKey::EScope scope); + // called back when the commit finishes + void commitSettingsFinished(LLEnvKey::EScope scope); + + /* + * notify of changes in god/not-god mode, estate ownership, etc. + * should be called every time after entering new region (after receiving new caps) + */ + void notifyPermissionChange(); + + bool regionCapable(); + static const std::string getScopeString(LLEnvKey::EScope scope); + bool canEdit(LLEnvKey::EScope scope); + // enables and populates UI + // populates display (param managers) with scope's settings + // silently fails if canEdit(scope) is false! + void startEditingScope(LLEnvKey::EScope scope); + // cancel and close UI as necessary + // reapplies unedited settings + // displays the settings from the scope that user has set (i.e. opt-in setting for now) + void maybeClearEditingScope(bool user_initiated, bool was_commit); + // clear the scope only if was editing that scope + void maybeClearEditingScope(LLEnvKey::EScope scope, bool user_initiated, bool was_commit); + // actually do the clearing + void clearEditingScope(const LLSD& notification, const LLSD& response); + + // clear and reload defaults into scope + void resetInternalsToDefault(LLEnvKey::EScope scope); + + // sets which scope is to be displayed + // fix me if/when adding more levels of scope + void setNormallyDisplayedScope(LLEnvKey::EScope scope); + +private: + // overriden initializer + friend class LLSingleton; + virtual void initSingleton(); + // helper function (when region changes, but before caps are received) + void changedRegion(bool interpolate); + // apply to current display and UI + void loadSettingsIntoManagers(LLEnvKey::EScope scope, bool interpolate); + // save from current display and UI into memory (mOrigSettingStore) + void saveSettingsFromManagers(LLEnvKey::EScope scope); + + // Save copy of settings from the current ones in the param managers + LLEnvironmentSettings collateFromParamManagers(); + // bundle settings (already committed from UI) into an LLSD + LLSD makePacket(LLEnvKey::EScope scope, const LLSD& metadata); + + void updateUIFromEditability(); + + // only call when setting *changes*, not just when it might have changed + // saves local settings into mOrigSettingStore when necessary + void notifyOptInChange(); + + // calculate Linden default settings + static const LLEnvironmentSettings& lindenDefaults(); + + std::map mOrigSettingStore; // settings which have been committed from UI + + bool mInterpNextChangeMessage; + bool mPendingOutgoingMessage; + bool mIsEditing; + LLEnvKey::EScope mCurNormalScope; // scope being displayed when not editing (i.e. most of the time) + LLEnvKey::EScope mCurEditingScope; + LLUUID mLastReceivedID; +}; + +#endif // LL_LLENVMANAGER_H + diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index 22816ee802..efaac5cfc5 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -2,25 +2,31 @@ * @file llfloaterdaycycle.cpp * @brief LLFloaterDayCycle class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -51,34 +57,23 @@ #include "llwlparammanager.h" #include "llpostprocess.h" #include "llfloaterwindlight.h" +#include "llwindlightscrubbers.h" +#include "llenvmanager.h" - -std::map LLFloaterDayCycle::sSliderToKey; +LLFloaterDayCycle* LLFloaterDayCycle::sDayCycle = NULL; const F32 LLFloaterDayCycle::sHoursPerDay = 24.0f; +std::map LLFloaterDayCycle::sSliderToKey; +LLEnvKey::EScope LLFloaterDayCycle::sScope; +std::string LLFloaterDayCycle::sOriginalTitle; +LLWLAnimator::ETime LLFloaterDayCycle::sPreviousTimeType = LLWLAnimator::TIME_LINDEN; -LLFloaterDayCycle::LLFloaterDayCycle(const LLSD& key) -: LLFloater(key) +LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater(std::string("Day Cycle Floater")) { -} + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_day_cycle_options.xml", NULL, FALSE); + sOriginalTitle = getTitle(); -BOOL LLFloaterDayCycle::postBuild() -{ - // add the combo boxes - LLComboBox* keyCombo = getChild("WLKeyPresets"); - - if(keyCombo != NULL) - { - keyCombo->removeall(); - std::map::iterator mIt = - LLWLParamManager::instance()->mParamList.begin(); - for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) - { - keyCombo->add(std::string(mIt->first)); - } - - // set defaults on combo boxes - keyCombo->selectFirstItem(); - } + llassert(MAX_LOCAL_KEY_FRAMES <= getChild("WLDayCycleKeys")->getMaxSliderCount() && + MAX_REGION_KEYFRAMES <= getChild("WLDayCycleKeys")->getMaxSliderCount()); // add the time slider LLMultiSliderCtrl* sldr = getChild("WLTimeSlider"); @@ -87,57 +82,67 @@ BOOL LLFloaterDayCycle::postBuild() // load it up initCallbacks(); - - syncMenu(); - syncSliderTrack(); - - return TRUE; } LLFloaterDayCycle::~LLFloaterDayCycle() { } +void LLFloaterDayCycle::onClickHelp(void* data) +{ + LLFloaterDayCycle* self = LLFloaterDayCycle::instance(); + + std::string xml_alert = *(std::string *) data; + LLNotifications::instance().add(self->contextualNotification(xml_alert)); +} + +void LLFloaterDayCycle::initHelpBtn(const std::string& name, const std::string& xml_alert) +{ + childSetAction(name, onClickHelp, new std::string(xml_alert)); +} + void LLFloaterDayCycle::initCallbacks(void) { + initHelpBtn("WLDayCycleHelp", "HelpDayCycle"); + // WL Day Cycle - getChild("WLTimeSlider")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeSliderMoved, this, _1)); - getChild("WLDayCycleKeys")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyTimeMoved, this, _1)); - getChild("WLCurKeyHour")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyTimeChanged, this, _1)); - getChild("WLCurKeyMin")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyTimeChanged, this, _1)); - getChild("WLKeyPresets")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyPresetChanged, this, _1)); - - getChild("WLLengthOfDayHour")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeRateChanged, this, _1)); - getChild("WLLengthOfDayMin")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeRateChanged, this, _1)); - getChild("WLLengthOfDaySec")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeRateChanged, this, _1)); - getChild("WLUseLindenTime")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onUseLindenTime, this, _1)); - getChild("WLAnimSky")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onRunAnimSky, this, _1)); - getChild("WLStopAnimSky")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onStopAnimSky, this, _1)); - - getChild("WLLoadDayCycle")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onLoadDayCycle, this, _1)); - getChild("WLSaveDayCycle")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onSaveDayCycle, this, _1)); - - getChild("WLAddKey")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onAddKey, this, _1)); - getChild("WLDeleteKey")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onDeleteKey, this, _1)); + childSetCommitCallback("WLTimeSlider", onTimeSliderMoved, NULL); + childSetCommitCallback("WLDayCycleKeys", onKeyTimeMoved, NULL); + childSetCommitCallback("WLCurKeyHour", onKeyTimeChanged, NULL); + childSetCommitCallback("WLCurKeyMin", onKeyTimeChanged, NULL); + childSetCommitCallback("WLKeyPresets", onKeyPresetChanged, NULL); + + childSetCommitCallback("WLLengthOfDayHour", onTimeRateChanged, NULL); + childSetCommitCallback("WLLengthOfDayMin", onTimeRateChanged, NULL); + childSetCommitCallback("WLLengthOfDaySec", onTimeRateChanged, NULL); + childSetAction("WLUseLindenTime", onUseLindenTime, NULL); + childSetAction("WLAnimSky", onRunAnimSky, NULL); + childSetAction("WLStopAnimSky", onStopAnimSky, NULL); + + childSetAction("WLLoadDayCycle", onLoadDayCycle, NULL); + childSetAction("WLSaveDayCycle", onSaveDayCycle, NULL); + + childSetAction("WLAddKey", onAddKey, NULL); + childSetAction("WLDeleteKey", onDeleteKey, NULL); } void LLFloaterDayCycle::syncMenu() { -// std::map & currentParams = LLWLParamManager::instance()->mCurParams.mParamValues; +// std::map & currentParams = LLWLParamManager::getInstance()->mCurParams.mParamValues; // set time - LLMultiSliderCtrl* sldr = getChild("WLTimeSlider"); - sldr->setCurSliderValue((F32)LLWLParamManager::instance()->mAnimator.getDayTime() * sHoursPerDay); + LLMultiSliderCtrl* sldr = LLFloaterDayCycle::sDayCycle->getChild("WLTimeSlider"); + sldr->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); - LLSpinCtrl* secSpin = getChild("WLLengthOfDaySec"); - LLSpinCtrl* minSpin = getChild("WLLengthOfDayMin"); - LLSpinCtrl* hourSpin = getChild("WLLengthOfDayHour"); + LLSpinCtrl* secSpin = sDayCycle->getChild("WLLengthOfDaySec"); + LLSpinCtrl* minSpin = sDayCycle->getChild("WLLengthOfDayMin"); + LLSpinCtrl* hourSpin = sDayCycle->getChild("WLLengthOfDayHour"); F32 curRate; F32 hours, min, sec; // get the current rate - curRate = LLWLParamManager::instance()->mDay.mDayRate; + curRate = LLWLParamManager::getInstance()->mDay.mDayRate; hours = (F32)((int)(curRate / 60 / 60)); curRate -= (hours * 60 * 60); min = (F32)((int)(curRate / 60)); @@ -149,28 +154,28 @@ void LLFloaterDayCycle::syncMenu() secSpin->setValue(sec); // turn off Use Estate Time button if it's already being used - if( LLWLParamManager::instance()->mAnimator.mUseLindenTime == true) + if( LLWLParamManager::getInstance()->mAnimator.getUseLindenTime()) { - getChildView("WLUseLindenTime")->setEnabled(FALSE); + LLFloaterDayCycle::sDayCycle->childDisable("WLUseLindenTime"); } else { - getChildView("WLUseLindenTime")->setEnabled(TRUE); + LLFloaterDayCycle::sDayCycle->childEnable("WLUseLindenTime"); } } void LLFloaterDayCycle::syncSliderTrack() { // clear the slider - LLMultiSliderCtrl* kSldr = getChild("WLDayCycleKeys"); + LLMultiSliderCtrl* kSldr = sDayCycle->getChild("WLDayCycleKeys"); kSldr->clear(); sSliderToKey.clear(); // add sliders - std::map::iterator mIt = - LLWLParamManager::instance()->mDay.mTimeMap.begin(); - for(; mIt != LLWLParamManager::instance()->mDay.mTimeMap.end(); mIt++) + std::map::iterator mIt = + LLWLParamManager::getInstance()->mDay.mTimeMap.begin(); + for(; mIt != LLWLParamManager::getInstance()->mDay.mTimeMap.end(); mIt++) { addSliderKey(mIt->first * sHoursPerDay, mIt->second); } @@ -185,34 +190,115 @@ void LLFloaterDayCycle::syncTrack() } LLMultiSliderCtrl* sldr; - sldr = getChild( + sldr = sDayCycle->getChild( "WLDayCycleKeys"); llassert_always(sSliderToKey.size() == sldr->getValue().size()); LLMultiSliderCtrl* tSldr; - tSldr = getChild( + tSldr = sDayCycle->getChild( "WLTimeSlider"); // create a new animation track - LLWLParamManager::instance()->mDay.clearKeys(); + LLWLParamManager::getInstance()->mDay.clearKeyframes(); // add the keys one by one - std::map::iterator mIt = sSliderToKey.begin(); + std::map::iterator mIt = sSliderToKey.begin(); for(; mIt != sSliderToKey.end(); mIt++) { - LLWLParamManager::instance()->mDay.addKey(mIt->second.time / sHoursPerDay, - mIt->second.presetName); + LLWLParamManager::getInstance()->mDay.addKeyframe(mIt->second.time / sHoursPerDay, + mIt->second.keyframe); } // set the param manager's track to the new one - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, false); - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); +} + +void LLFloaterDayCycle::refreshPresetsFromParamManager() +{ + LLComboBox* keyCombo = sDayCycle->getChild("WLKeyPresets"); + + if(keyCombo != NULL) + { + std::map::iterator mIt = + LLWLParamManager::getInstance()->mParamList.begin(); + for(; mIt != LLWLParamManager::getInstance()->mParamList.end(); mIt++) + { + if(mIt->first.scope <= sScope) + { + llinfos << "Adding key: " << mIt->first.toString() << llendl; + keyCombo->add(mIt->first.toString(), LLSD(mIt->first.toStringVal())); + } + } + + // set defaults on combo boxes + keyCombo->selectFirstItem(); + } } -void LLFloaterDayCycle::onRunAnimSky(LLUICtrl* ctrl) +// static +LLFloaterDayCycle* LLFloaterDayCycle::instance() +{ + if (!sDayCycle) + { + sDayCycle = new LLFloaterDayCycle(); + // sDayCycle->open(); + // sDayCycle->setFocus(TRUE); + } + return sDayCycle; +} + +bool LLFloaterDayCycle::isOpen() +{ + if (sDayCycle != NULL) + { + return true; + } + return false; +} + +void LLFloaterDayCycle::show(LLEnvKey::EScope scope) +{ + LLFloaterDayCycle* dayCycle = instance(); + if(scope != sScope && ((LLView*)dayCycle)->getVisible()) + { + LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD()); + return; + } + sScope = scope; + std::string title = sOriginalTitle + " (" + LLEnvManager::getScopeString(sScope) + ")"; + dayCycle->setTitle(title); + refreshPresetsFromParamManager(); + dayCycle->syncMenu(); + syncSliderTrack(); + + // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially) + const std::string& curSldr = sDayCycle->getChild("WLDayCycleKeys")->getCurSlider(); + if(strlen(curSldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map + { + sDayCycle->getChild("WLKeyPresets")->selectByValue(sSliderToKey[curSldr].keyframe.toStringVal()); + } + + // comment in if you want the menu to rebuild each time + //LLUICtrlFactory::getInstance()->buildFloater(dayCycle, "floater_day_cycle_options.xml"); + //dayCycle->initCallbacks(); + + dayCycle->open(); +} + +// virtual +void LLFloaterDayCycle::onClose(bool app_quitting) +{ + if (sDayCycle) + { + sDayCycle->setVisible(FALSE); + } +} + +void LLFloaterDayCycle::onRunAnimSky(void* userData) { // if no keys, do nothing if(sSliderToKey.size() == 0) @@ -221,46 +307,47 @@ void LLFloaterDayCycle::onRunAnimSky(LLUICtrl* ctrl) } LLMultiSliderCtrl* sldr; - sldr = getChild("WLDayCycleKeys"); + sldr = sDayCycle->getChild("WLDayCycleKeys"); llassert_always(sSliderToKey.size() == sldr->getValue().size()); - LLMultiSliderCtrl* tSldr; - tSldr = getChild("WLTimeSlider"); + LLMultiSliderCtrl* tSldr = sDayCycle->getChild("WLTimeSlider"); + + sPreviousTimeType = LLWLParamManager::getInstance()->mAnimator.getTimeType(); // turn off linden time - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setTimeType(LLWLAnimator::TIME_CUSTOM); // set the param manager's track to the new one - LLWLParamManager::instance()->resetAnimator( - tSldr->getCurSliderValue() / sHoursPerDay, true); + LLWLParamManager::getInstance()->resetAnimator(tSldr->getCurSliderValue() / sHoursPerDay, true); - llassert_always(LLWLParamManager::instance()->mAnimator.mTimeTrack.size() == sldr->getValue().size()); + llassert_always(LLWLParamManager::getInstance()->mAnimator.mTimeTrack.size() == sldr->getValue().size()); } -void LLFloaterDayCycle::onStopAnimSky(LLUICtrl* ctrl) +void LLFloaterDayCycle::onStopAnimSky(void* userData) { // if no keys, do nothing if(sSliderToKey.size() == 0) { return; } - // turn off animation and using linden time - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.deactivate(); // turn off animation and using linden time + LLMultiSliderCtrl* tSldr = sDayCycle->getChild("WLTimeSlider"); + LLWLParamManager::getInstance()->resetAnimator(tSldr->getCurSliderValue() / sHoursPerDay, false); + LLWLParamManager::getInstance()->mAnimator.setTimeType(sPreviousTimeType); } -void LLFloaterDayCycle::onUseLindenTime(LLUICtrl* ctrl) +void LLFloaterDayCycle::onUseLindenTime(void* userData) { - LLComboBox* box = getChild("WLPresetsCombo"); + LLFloaterWindLight* wl = LLFloaterWindLight::instance(); + LLComboBox* box = wl->getChild("WLPresetsCombo"); box->selectByValue(""); - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.deactivate(); } -void LLFloaterDayCycle::onLoadDayCycle(LLUICtrl* ctrl) +void LLFloaterDayCycle::onLoadDayCycle(void* userData) { - LLWLParamManager::instance()->mDay.loadDayCycle("Default.xml"); + LLWLParamManager::getInstance()->mDay.loadDayCycleFromFile("Default.xml"); // sync it all up syncSliderTrack(); @@ -268,46 +355,45 @@ void LLFloaterDayCycle::onLoadDayCycle(LLUICtrl* ctrl) // set the param manager's track to the new one LLMultiSliderCtrl* tSldr; - tSldr = getChild( + tSldr = sDayCycle->getChild( "WLTimeSlider"); - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, false); // and draw it - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } -void LLFloaterDayCycle::onSaveDayCycle(LLUICtrl* ctrl) +void LLFloaterDayCycle::onSaveDayCycle(void* userData) { - LLWLParamManager::instance()->mDay.saveDayCycle("Default.xml"); + LLWLParamManager::getInstance()->mDay.saveDayCycle("Default.xml"); } -void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl) +void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl, void* userData) { - LLMultiSliderCtrl* sldr = getChild( + LLMultiSliderCtrl* sldr = sDayCycle->getChild( "WLTimeSlider"); /// get the slider value F32 val = sldr->getCurSliderValue() / sHoursPerDay; // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); + LLWLParamManager::getInstance()->mAnimator.deactivate(); // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } -void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl) +void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl, void* userData) { - LLComboBox* comboBox = getChild("WLKeyPresets"); - LLMultiSliderCtrl* sldr = getChild("WLDayCycleKeys"); - LLSpinCtrl* hourSpin = getChild("WLCurKeyHour"); - LLSpinCtrl* minSpin = getChild("WLCurKeyMin"); + LLComboBox* comboBox = sDayCycle->getChild("WLKeyPresets"); + LLMultiSliderCtrl* sldr = sDayCycle->getChild("WLDayCycleKeys"); + LLSpinCtrl* hourSpin = sDayCycle->getChild("WLCurKeyHour"); + LLSpinCtrl* minSpin = sDayCycle->getChild("WLCurKeyMin"); if(sldr->getValue().size() == 0) { return; @@ -322,11 +408,11 @@ void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl) F32 time = sldr->getCurSliderValue(); // check to see if a key exists - std::string presetName = sSliderToKey[curSldr].presetName; + LLWLParamKey key = sSliderToKey[curSldr].keyframe; sSliderToKey[curSldr].time = time; // if it exists, turn on check box - comboBox->selectByValue(presetName); + comboBox->selectByValue(key.toStringVal()); // now set the spinners F32 hour = (F32)((S32)time); @@ -345,18 +431,18 @@ void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl) } -void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl) +void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl, void* userData) { // if no keys, skipped if(sSliderToKey.size() == 0) { return; } - LLMultiSliderCtrl* sldr = getChild( + LLMultiSliderCtrl* sldr = sDayCycle->getChild( "WLDayCycleKeys"); - LLSpinCtrl* hourSpin = getChild( + LLSpinCtrl* hourSpin = sDayCycle->getChild( "WLCurKeyHour"); - LLSpinCtrl* minSpin = getChild( + LLSpinCtrl* minSpin = sDayCycle->getChild( "WLCurKeyMin"); F32 hour = hourSpin->get(); @@ -368,18 +454,17 @@ void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl) F32 time = sldr->getCurSliderValue() / sHoursPerDay; // now set the key's time in the sliderToKey map - std::string presetName = sSliderToKey[curSldr].presetName; sSliderToKey[curSldr].time = time; syncTrack(); } -void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl) +void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl, void* userData) { // get the time - LLComboBox* comboBox = getChild( + LLComboBox* comboBox = sDayCycle->getChild( "WLKeyPresets"); - LLMultiSliderCtrl* sldr = getChild( + LLMultiSliderCtrl* sldr = sDayCycle->getChild( "WLDayCycleKeys"); // do nothing if no sliders @@ -388,7 +473,9 @@ void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl) } // change the map - std::string newPreset(comboBox->getSelectedValue().asString()); + + std::string stringVal = comboBox->getSelectedValue().asString(); + LLWLParamKey newKey(stringVal); const std::string& curSldr = sldr->getCurSlider(); // if null, don't use @@ -396,21 +483,21 @@ void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl) return; } - sSliderToKey[curSldr].presetName = newPreset; + sSliderToKey[curSldr].keyframe = newKey; syncTrack(); } -void LLFloaterDayCycle::onTimeRateChanged(LLUICtrl* ctrl) +void LLFloaterDayCycle::onTimeRateChanged(LLUICtrl* ctrl, void* userData) { // get the time - LLSpinCtrl* secSpin = getChild( + LLSpinCtrl* secSpin = sDayCycle->getChild( "WLLengthOfDaySec"); - LLSpinCtrl* minSpin = getChild( + LLSpinCtrl* minSpin = sDayCycle->getChild( "WLLengthOfDayMin"); - LLSpinCtrl* hourSpin = getChild( + LLSpinCtrl* hourSpin = sDayCycle->getChild( "WLLengthOfDayHour"); F32 hour; @@ -424,34 +511,57 @@ void LLFloaterDayCycle::onTimeRateChanged(LLUICtrl* ctrl) if(time <= 0) { time = 1; } - LLWLParamManager::instance()->mDay.mDayRate = time; + LLWLParamManager::getInstance()->mDay.mDayRate = time; syncTrack(); } -void LLFloaterDayCycle::onAddKey(LLUICtrl* ctrl) +void LLFloaterDayCycle::onAddKey(void* userData) { - LLComboBox* comboBox = getChild( + LLComboBox* comboBox = sDayCycle->getChild( "WLKeyPresets"); - LLMultiSliderCtrl* kSldr = getChild( + LLMultiSliderCtrl* kSldr = sDayCycle->getChild( "WLDayCycleKeys"); - LLMultiSliderCtrl* tSldr = getChild( + LLMultiSliderCtrl* tSldr = sDayCycle->getChild( "WLTimeSlider"); llassert_always(sSliderToKey.size() == kSldr->getValue().size()); + S32 max_sliders; + switch(sScope) + { + case LLEnvKey::SCOPE_LOCAL: + max_sliders = LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES; + break; + case LLEnvKey::SCOPE_REGION: + max_sliders = LLWLPacketScrubber::MAX_REGION_KEY_FRAMES; + break; + default: + max_sliders = kSldr->getMaxSliderCount(); + break; + } + + if(kSldr->getSliderCount() >= max_sliders) + { + LLSD args; + args["SCOPE"] = LLEnvManager::getScopeString(sScope); + args["MAX"] = max_sliders; + LLNotifications::instance().add("DayCycleTooManyKeyframes", args); + return; + } + // get the values - std::string newPreset(comboBox->getSelectedValue().asString()); + LLWLParamKey newKeyframe(comboBox->getSelectedValue()); // add the slider key - addSliderKey(tSldr->getCurSliderValue(), newPreset); + addSliderKey(tSldr->getCurSliderValue(), newKeyframe); syncTrack(); } -void LLFloaterDayCycle::addSliderKey(F32 time, const std::string & presetName) +void LLFloaterDayCycle::addSliderKey(F32 time, LLWLParamKey keyframe) { - LLMultiSliderCtrl* kSldr = getChild( + LLMultiSliderCtrl* kSldr = sDayCycle->getChild( "WLDayCycleKeys"); // make a slider @@ -461,30 +571,28 @@ void LLFloaterDayCycle::addSliderKey(F32 time, const std::string & presetName) } // set the key - LLWLSkyKey newKey; - newKey.presetName = presetName; - newKey.time = kSldr->getCurSliderValue(); + LLWLCycleSliderKey newKey(keyframe, kSldr->getCurSliderValue()); llassert_always(sldrName != LLStringUtil::null); // add to map - sSliderToKey.insert(std::pair(sldrName, newKey)); + sSliderToKey.insert(std::pair(sldrName, newKey)); llassert_always(sSliderToKey.size() == kSldr->getValue().size()); } -void LLFloaterDayCycle::deletePreset(std::string& presetName) +void LLFloaterDayCycle::deletePreset(LLWLParamKey keyframe) { - LLMultiSliderCtrl* sldr = getChild("WLDayCycleKeys"); + LLMultiSliderCtrl* sldr = sDayCycle->getChild("WLDayCycleKeys"); /// delete any reference - std::map::iterator curr_preset, next_preset; + std::map::iterator curr_preset, next_preset; for(curr_preset = sSliderToKey.begin(); curr_preset != sSliderToKey.end(); curr_preset = next_preset) { next_preset = curr_preset; ++next_preset; - if (curr_preset->second.presetName == presetName) + if (curr_preset->second.keyframe == keyframe) { sldr->deleteSlider(curr_preset->first); sSliderToKey.erase(curr_preset); @@ -492,19 +600,25 @@ void LLFloaterDayCycle::deletePreset(std::string& presetName) } } -void LLFloaterDayCycle::onDeleteKey(LLUICtrl* ctrl) +void LLFloaterDayCycle::onDeleteKey(void* userData) { - if(sSliderToKey.size() == 0) { + if(sSliderToKey.size() == 0) + { + return; + } + else if(sSliderToKey.size() == 1) + { + LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD()); return; } - LLComboBox* comboBox = getChild( + LLComboBox* comboBox = sDayCycle->getChild( "WLKeyPresets"); - LLMultiSliderCtrl* sldr = getChild("WLDayCycleKeys"); + LLMultiSliderCtrl* sldr = sDayCycle->getChild("WLDayCycleKeys"); // delete from map const std::string& sldrName = sldr->getCurSlider(); - std::map::iterator mIt = sSliderToKey.find(sldrName); + std::map::iterator mIt = sSliderToKey.find(sldrName); sSliderToKey.erase(mIt); sldr->deleteCurSlider(); @@ -514,11 +628,11 @@ void LLFloaterDayCycle::onDeleteKey(LLUICtrl* ctrl) } const std::string& name = sldr->getCurSlider(); - comboBox->selectByValue(sSliderToKey[name].presetName); + comboBox->selectByValue(sSliderToKey[name].keyframe.toLLSD()); F32 time = sSliderToKey[name].time; - LLSpinCtrl* hourSpin = getChild("WLCurKeyHour"); - LLSpinCtrl* minSpin = getChild("WLCurKeyMin"); + LLSpinCtrl* hourSpin = sDayCycle->getChild("WLCurKeyHour"); + LLSpinCtrl* minSpin = sDayCycle->getChild("WLCurKeyMin"); // now set the spinners F32 hour = (F32)((S32)time); diff --git a/indra/newview/llfloaterdaycycle.h b/indra/newview/llfloaterdaycycle.h index 993ddb8f07..1c021f0c6a 100644 --- a/indra/newview/llfloaterdaycycle.h +++ b/indra/newview/llfloaterdaycycle.h @@ -2,25 +2,31 @@ * @file llfloaterdaycycle.h * @brief LLFloaterDayCycle class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -32,15 +38,19 @@ #include #include "llwlparamset.h" #include "llwlanimator.h" +#include "llwlparammanager.h" struct WLColorControl; struct WLFloatControl; -/// convenience class for holding keys mapped to sliders -struct LLWLSkyKey +/// convenience class for holding keyframes mapped to sliders +struct LLWLCycleSliderKey { public: - std::string presetName; + LLWLCycleSliderKey(LLWLParamKey kf, F32 t) : keyframe(kf), time(t) {} + LLWLCycleSliderKey() : keyframe(), time(0.f) {} // Don't use this default constructor + + LLWLParamKey keyframe; F32 time; }; @@ -49,71 +59,94 @@ public: class LLFloaterDayCycle : public LLFloater { public: - - LLFloaterDayCycle(const LLSD& key); + LLFloaterDayCycle(); virtual ~LLFloaterDayCycle(); - /*virtual*/ BOOL postBuild(); + + // map of sliders to parameters + static std::map sSliderToKey; + + /// help button stuff + static void onClickHelp(void* data); + void initHelpBtn(const std::string& name, const std::string& xml_alert); /// initialize all void initCallbacks(void); + /// one and one instance only + static LLFloaterDayCycle* instance(); + /// on time slider moved - void onTimeSliderMoved(LLUICtrl* ctrl); + static void onTimeSliderMoved(LLUICtrl* ctrl, void* userData); /// what happens when you move the key frame - void onKeyTimeMoved(LLUICtrl* ctrl); + static void onKeyTimeMoved(LLUICtrl* ctrl, void* userData); /// what happens when you change the key frame's time - void onKeyTimeChanged(LLUICtrl* ctrl); + static void onKeyTimeChanged(LLUICtrl* ctrl, void* userData); /// if you change the combo box, change the frame - void onKeyPresetChanged(LLUICtrl* ctrl); + static void onKeyPresetChanged(LLUICtrl* ctrl, void* userData); /// run this when user says to run the sky animation - void onRunAnimSky(LLUICtrl* ctrl); + static void onRunAnimSky(void* userData); /// run this when user says to stop the sky animation - void onStopAnimSky(LLUICtrl* ctrl); + static void onStopAnimSky(void* userData); /// if you change the combo box, change the frame - void onTimeRateChanged(LLUICtrl* ctrl); + static void onTimeRateChanged(LLUICtrl* ctrl, void* userData); /// add a new key on slider - void onAddKey(LLUICtrl* ctrl); + static void onAddKey(void* userData); /// delete any and all reference to a preset - void deletePreset(std::string& presetName); + void deletePreset(LLWLParamKey keyframe); /// delete a key frame - void onDeleteKey(LLUICtrl* ctrl); + static void onDeleteKey(void* userData); /// button to load day - void onLoadDayCycle(LLUICtrl* ctrl); + static void onLoadDayCycle(void* userData); /// button to save day - void onSaveDayCycle(LLUICtrl* ctrl); + static void onSaveDayCycle(void* userData); /// toggle for Linden time - void onUseLindenTime(LLUICtrl* ctrl); + static void onUseLindenTime(void* userData); + + + //// menu management + + /// show off our menu + static void show(LLEnvKey::EScope scope = LLEnvKey::SCOPE_LOCAL); + + /// return if the menu exists or not + static bool isOpen(); + + /// stuff to do on exit + virtual void onClose(bool app_quitting); /// sync up sliders with day cycle structure - void syncMenu(); + static void syncMenu(); // makes sure key slider has what's in day cycle - void syncSliderTrack(); + static void syncSliderTrack(); /// makes sure day cycle data structure has what's in menu - void syncTrack(); + static void syncTrack(); + + /// refresh combox box from param manager + static void refreshPresetsFromParamManager(); /// add a slider to the track - void addSliderKey(F32 time, const std::string& presetName); + static void addSliderKey(F32 time, LLWLParamKey keyframe); private: - - // map of sliders to parameters - static std::map sSliderToKey; - + static LLFloaterDayCycle* sDayCycle; // one instance on the inside static const F32 sHoursPerDay; + static LLEnvKey::EScope sScope; + static std::string sOriginalTitle; + static LLWLAnimator::ETime sPreviousTimeType; }; diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index fcaef1f34b..6d1b27db07 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -2,25 +2,31 @@ * @file llfloaterenvsettings.cpp * @brief LLFloaterEnvSettings class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -28,9 +34,10 @@ #include "llfloaterenvsettings.h" -#include "llfloaterreg.h" #include "llfloaterwindlight.h" #include "llfloaterwater.h" +#include "llfloaterdaycycle.h" +#include "llfloaterregioninfo.h" #include "lluictrlfactory.h" #include "llsliderctrl.h" #include "llcombobox.h" @@ -42,57 +49,89 @@ #include "llwaterparammanager.h" #include "llmath.h" #include "llviewerwindow.h" +#include "llviewercontrol.h" + +#include "llcheckboxctrl.h" #include "pipeline.h" #include -LLFloaterEnvSettings::LLFloaterEnvSettings(const LLSD& key) - : LLFloater(key) +LLFloaterEnvSettings* LLFloaterEnvSettings::sEnvSettings = NULL; + +LLFloaterEnvSettings::LLFloaterEnvSettings() : LLFloater(std::string("Environment Settings Floater")) { + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_env_settings.xml", NULL, FALSE); + + // load it up + initCallbacks(); } -// virtual + LLFloaterEnvSettings::~LLFloaterEnvSettings() { } -// virtual -BOOL LLFloaterEnvSettings::postBuild() -{ - // load it up - initCallbacks(); - syncMenu(); - return TRUE; + +void LLFloaterEnvSettings::onClickHelp(void* data) +{ + LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data; + LLNotifications::instance().add(self->contextualNotification("EnvSettingsHelpButton")); +} + +void LLFloaterEnvSettings::onUseRegionEnvironment(LLUICtrl* ctrl, void* data) +{ + LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data; + LLCheckBoxCtrl* checkbox = (LLCheckBoxCtrl*)self->getChildView("RegionWLOptIn"); + setOptIn(checkbox->getValue().asBoolean()); +} + +void LLFloaterEnvSettings::setOptIn(bool opt_in) +{ + if (opt_in) + { + LLEnvManager::getInstance()->setNormallyDisplayedScope(LLEnvKey::SCOPE_REGION); + } + else + { + LLEnvManager::getInstance()->setNormallyDisplayedScope(LLEnvKey::SCOPE_LOCAL); + } } void LLFloaterEnvSettings::initCallbacks(void) { // our three sliders - getChild("EnvTimeSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeDayTime, this, _1)); - getChild("EnvCloudSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeCloudCoverage, this, _1)); - getChild("EnvWaterFogSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeWaterFogDensity, this, _1, &LLWaterParamManager::instance()->mFogDensity)); + childSetCommitCallback("EnvTimeSlider", onChangeDayTime, NULL); + childSetCommitCallback("EnvCloudSlider", onChangeCloudCoverage, NULL); + childSetCommitCallback("EnvWaterFogSlider", onChangeWaterFogDensity, + &LLWaterParamManager::getInstance()->mFogDensity); // color picker - getChild("EnvWaterColor")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeWaterColor, this, _1, &LLWaterParamManager::instance()->mFogColor)); + childSetCommitCallback("EnvWaterColor", onChangeWaterColor, + &LLWaterParamManager::getInstance()->mFogColor); // WL Top - getChild("EnvAdvancedSkyButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onOpenAdvancedSky, this)); - getChild("EnvAdvancedWaterButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onOpenAdvancedWater, this)); - getChild("EnvUseEstateTimeButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onUseEstateTime, this)); + childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL); + childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, NULL); + childSetAction("EnvUseEstateTimeButton", onUseEstateTime, NULL); + childSetAction("EnvUseLocalTimeButton", onUseLocalTime, NULL); + childSetAction("EnvSettingsHelpButton", onClickHelp, this); + + childSetCommitCallback("RegionWLOptIn", onUseRegionEnvironment, this); } + // menu maintenance functions void LLFloaterEnvSettings::syncMenu() { LLSliderCtrl* sldr; - sldr = getChild("EnvTimeSlider"); + sldr = sEnvSettings->getChild("EnvTimeSlider"); // sync the clock - F32 val = (F32)LLWLParamManager::instance()->mAnimator.getDayTime(); - std::string timeStr = timeToString(val); + F32 val = (F32)LLWLParamManager::getInstance()->mAnimator.getDayTime(); + std::string timeStr = LLWLAnimator::timeToString(val); LLTextBox* textBox; - textBox = getChild("EnvTimeText"); + textBox = sEnvSettings->getChild("EnvTimeText"); textBox->setValue(timeStr); @@ -106,62 +145,159 @@ void LLFloaterEnvSettings::syncMenu() // sync cloud coverage bool err; - getChild("EnvCloudSlider")->setValue(LLWLParamManager::instance()->mCurParams.getFloat("cloud_shadow", err)); + childSetValue("EnvCloudSlider", LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_shadow", err)); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); // sync water params LLColor4 col = param_mgr->getFogColor(); - LLColorSwatchCtrl* colCtrl = getChild("EnvWaterColor"); + LLColorSwatchCtrl* colCtrl = sEnvSettings->getChild("EnvWaterColor"); col.mV[3] = 1.0f; colCtrl->set(col); - getChild("EnvWaterFogSlider")->setValue(param_mgr->mFogDensity.mExp); + childSetValue("EnvWaterFogSlider", param_mgr->mFogDensity.mExp); param_mgr->setDensitySliderValue(param_mgr->mFogDensity.mExp); - // turn off Use Estate Time button if it's already being used - if(LLWLParamManager::instance()->mAnimator.mUseLindenTime) + // turn off Use Estate/Local Time buttons if already being used + + if(LLWLParamManager::getInstance()->mAnimator.getUseLindenTime()) { - getChildView("EnvUseEstateTimeButton")->setEnabled(FALSE); - } else { - getChildView("EnvUseEstateTimeButton")->setEnabled(TRUE); + childDisable("EnvUseEstateTimeButton"); + } + else + { + childEnable("EnvUseEstateTimeButton"); + } + + if(LLWLParamManager::getInstance()->mAnimator.getUseLocalTime()) + { + childDisable("EnvUseLocalTimeButton"); + } + else + { + childEnable("EnvUseLocalTimeButton"); } if(!gPipeline.canUseVertexShaders()) { - getChildView("EnvWaterColor")->setEnabled(FALSE); - getChildView("EnvWaterColorText")->setEnabled(FALSE); - //getChildView("EnvAdvancedWaterButton")->setEnabled(FALSE); + childDisable("EnvWaterColor"); + childDisable("EnvWaterColorText"); + //childDisable("EnvAdvancedWaterButton"); } else { - getChildView("EnvWaterColor")->setEnabled(TRUE); - getChildView("EnvWaterColorText")->setEnabled(TRUE); - //getChildView("EnvAdvancedWaterButton")->setEnabled(TRUE); + childEnable("EnvWaterColor"); + childEnable("EnvWaterColorText"); + //childEnable("EnvAdvancedWaterButton"); } // only allow access to these if they are using windlight if(!gPipeline.canUseWindLightShaders()) { - getChildView("EnvCloudSlider")->setEnabled(FALSE); - getChildView("EnvCloudText")->setEnabled(FALSE); - //getChildView("EnvAdvancedSkyButton")->setEnabled(FALSE); + childDisable("EnvCloudSlider"); + childDisable("EnvCloudText"); + //childDisable("EnvAdvancedSkyButton"); + } + else + { + childEnable("EnvCloudSlider"); + childEnable("EnvCloudText"); + //childEnable("EnvAdvancedSkyButton"); + } +} + + +// static instance of it +LLFloaterEnvSettings* LLFloaterEnvSettings::instance() +{ + if (!sEnvSettings) + { + sEnvSettings = new LLFloaterEnvSettings(); + // sEnvSettings->open(); + // sEnvSettings->setFocus(TRUE); + } + return sEnvSettings; +} + +void LLFloaterEnvSettings::setControlsEnabled(bool enable) +{ + if(enable) + { + // reenable UI elements, resync sliders, and reload saved settings + childEnable("EnvAdvancedSkyButton"); + childEnable("EnvAdvancedWaterButton"); + childEnable("EnvUseEstateTimeButton"); + childShow("EnvTimeText"); + childShow("EnvWaterColor"); + childShow("EnvTimeSlider"); + childShow("EnvCloudSlider"); + childShow("EnvWaterFogSlider"); + syncMenu(); } else { - getChildView("EnvCloudSlider")->setEnabled(TRUE); - getChildView("EnvCloudText")->setEnabled(TRUE); - //getChildView("EnvAdvancedSkyButton")->setEnabled(TRUE); + // disable UI elements the user shouldn't be able to see to protect potentially proprietary WL region settings from being visible + LLFloaterWindLight::instance()->close(); + LLFloaterWater::instance()->close(); + LLFloaterDayCycle::instance()->close(); + childDisable("EnvAdvancedSkyButton"); + childDisable("EnvAdvancedWaterButton"); + childDisable("EnvUseEstateTimeButton"); + childHide("EnvTimeText"); + childHide("EnvWaterColor"); + childHide("EnvTimeSlider"); + childHide("EnvCloudSlider"); + childHide("EnvWaterFogSlider"); } } -void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl) + +void LLFloaterEnvSettings::show() +{ + LLFloaterEnvSettings* envSettings = instance(); + envSettings->syncMenu(); + + // comment in if you want the menu to rebuild each time + //LLUICtrlFactory::getInstance()->buildFloater(envSettings, "floater_env_settings.xml"); + //envSettings->initCallbacks(); + + // Set environment opt-in checkbox based on saved value -- only need to do once, not every time syncMenu is called + + bool opt_in = gSavedSettings.getBOOL("UseEnvironmentFromRegion"); + + sEnvSettings->childSetVisible("RegionWLOptIn", LLEnvManager::getInstance()->regionCapable()); + sEnvSettings->setOptIn(opt_in); + sEnvSettings->getChildView("RegionWLOptIn")->setValue(LLSD::Boolean(opt_in)); + sEnvSettings->getChildView("RegionWLOptIn")->setToolTip(sEnvSettings->getString("region_environment_tooltip")); + envSettings->open(); +} + +bool LLFloaterEnvSettings::isOpen() { - LLSliderCtrl* sldr = static_cast(ctrl); + if (sEnvSettings != NULL) + { + return true; + } + return false; +} + +// virtual +void LLFloaterEnvSettings::onClose(bool app_quitting) +{ + if (sEnvSettings) + { + sEnvSettings->setVisible(FALSE); + } +} + + +void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData) +{ + LLSliderCtrl* sldr; + sldr = sEnvSettings->getChild("EnvTimeSlider"); // deactivate animator - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.deactivate(); F32 val = sldr->getValueF32() + 0.25f; if(val > 1.0) @@ -169,100 +305,81 @@ void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl) val--; } - LLWLParamManager::instance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } -void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl) +void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl, void* userData) { - LLSliderCtrl* sldr = static_cast(ctrl); + LLSliderCtrl* sldr; + sldr = sEnvSettings->getChild("EnvCloudSlider"); // deactivate animator - //LLWLParamManager::instance()->mAnimator.mIsRunning = false; - //LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + //LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + //LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; F32 val = sldr->getValueF32(); - LLWLParamManager::instance()->mCurParams.set("cloud_shadow", val); + LLWLParamManager::getInstance()->mCurParams.set("cloud_shadow", val); } -void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl) +void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, void* userData) { LLSliderCtrl* sldr; - sldr = getChild("EnvWaterFogSlider"); + sldr = sEnvSettings->getChild("EnvWaterFogSlider"); + + if(NULL == userData) + { + return; + } + + WaterExpFloatControl * expFloatControl = static_cast(userData); F32 val = sldr->getValueF32(); expFloatControl->mExp = val; - LLWaterParamManager::instance()->setDensitySliderValue(val); + LLWaterParamManager::getInstance()->setDensitySliderValue(val); - expFloatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } -void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, WaterColorControl* colorControl) +void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, void* userData) { LLColorSwatchCtrl* swatch = static_cast(ctrl); + WaterColorControl * colorControl = static_cast(userData); *colorControl = swatch->get(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } -void LLFloaterEnvSettings::onOpenAdvancedSky() +void LLFloaterEnvSettings::onOpenAdvancedSky(void* userData) { - LLFloaterReg::showInstance("env_windlight"); + LLFloaterWindLight::show(); } -void LLFloaterEnvSettings::onOpenAdvancedWater() +void LLFloaterEnvSettings::onOpenAdvancedWater(void* userData) { - LLFloaterReg::showInstance("env_water"); + LLFloaterWater::show(); } -void LLFloaterEnvSettings::onUseEstateTime() +void LLFloaterEnvSettings::onUseEstateTime(void* userData) { - LLFloaterWindLight* wl = LLFloaterReg::findTypedInstance("env_windlight"); - if(wl) + if(LLFloaterWindLight::isOpen()) { + // select the blank value in + LLFloaterWindLight* wl = LLFloaterWindLight::instance(); LLComboBox* box = wl->getChild("WLPresetsCombo"); box->selectByValue(""); } - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LINDEN); } -std::string LLFloaterEnvSettings::timeToString(F32 curTime) +void LLFloaterEnvSettings::onUseLocalTime(void* userData) { - S32 hours; - S32 min; - - // get hours and minutes - hours = (S32) (24.0 * curTime); - curTime -= ((F32) hours / 24.0f); - min = llround(24.0f * 60.0f * curTime); - - // handle case where it's 60 - if(min == 60) - { - hours++; - min = 0; - } - - std::string newTime = getString("timeStr"); - struct tm * timeT; - time_t secT = time(0); - timeT = gmtime (&secT); - - timeT->tm_hour = hours; - timeT->tm_min = min; - secT = mktime (timeT); - secT -= LLStringOps::getLocalTimeOffset (); - - LLSD substitution; - substitution["datetime"] = (S32) secT; - - LLStringUtil::format (newTime, substitution); - return newTime; + LLWLParamManager::getInstance()->mAnimator.setDayTime(LLWLAnimator::getLocalTime()); + LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LOCAL); } diff --git a/indra/newview/llfloaterenvsettings.h b/indra/newview/llfloaterenvsettings.h index a6280cfb97..0bf3e48676 100644 --- a/indra/newview/llfloaterenvsettings.h +++ b/indra/newview/llfloaterenvsettings.h @@ -2,25 +2,31 @@ * @file llfloaterskysettings.h * @brief LLFloaterEnvSettings class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -33,50 +39,77 @@ #include "llfloater.h" -struct WaterColorControl; -struct WaterExpFloatControl; /// Menuing system for all of windlight's functionality class LLFloaterEnvSettings : public LLFloater { public: - LLFloaterEnvSettings(const LLSD& key); - /*virtual*/ ~LLFloaterEnvSettings(); - /*virtual*/ BOOL postBuild(); + LLFloaterEnvSettings(); + virtual ~LLFloaterEnvSettings(); + /// initialize all the callbacks for the menu void initCallbacks(void); + /// one and one instance only + static LLFloaterEnvSettings* instance(); + + /// callback for the menus help button + static void onClickHelp(void* data); + /// handle if time of day is changed - void onChangeDayTime(LLUICtrl* ctrl); + static void onChangeDayTime(LLUICtrl* ctrl, void* userData); /// handle if cloud coverage is changed - void onChangeCloudCoverage(LLUICtrl* ctrl); + static void onChangeCloudCoverage(LLUICtrl* ctrl, void* userData); /// handle change in water fog density - void onChangeWaterFogDensity(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl); + static void onChangeWaterFogDensity(LLUICtrl* ctrl, void* userData); + + /// handle change in under water fog density + static void onChangeUnderWaterFogMod(LLUICtrl* ctrl, void* userData); /// handle change in water fog color - void onChangeWaterColor(LLUICtrl* ctrl, WaterColorControl* colorControl); + static void onChangeWaterColor(LLUICtrl* ctrl, void* userData); /// open the advanced sky settings menu - void onOpenAdvancedSky(); + static void onOpenAdvancedSky(void* userData); /// open the advanced water settings menu - void onOpenAdvancedWater(); + static void onOpenAdvancedWater(void* userData); /// sync time with the server - void onUseEstateTime(); + static void onUseEstateTime(void* userData); + + /// sync time with local clock + static void onUseLocalTime(void* userData); + + // opt-in for region Windlight settings + //static void onUseRegionEnvironment(LLUICtrl* ctrl, void* userData); + static void onUseRegionEnvironment(LLUICtrl*, void*); //// menu management + /// enables or disable all controls + void setControlsEnabled(bool enable); + + /// show off our menu + static void show(); + + /// return if the menu exists or not + static bool isOpen(); + + /// stuff to do on exit + virtual void onClose(bool app_quitting); + /// sync up sliders with parameters void syncMenu(); - /// convert the present time to a digital clock time - std::string timeToString(F32 curTime); - private: + // one instance on the inside + static LLFloaterEnvSettings* sEnvSettings; + + static void setOptIn(bool opt_in); }; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index ed81fdec16..f6377d50fa 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -40,6 +40,8 @@ #include "llxfermanager.h" #include "indra_constants.h" #include "message.h" +#include "llsd.h" +#include "llsdserialize.h" #include "llagent.h" #include "llappviewer.h" @@ -47,6 +49,7 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "llenvmanager.h" #include "llfilepicker.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() #include "llfloatertopobjects.h" // added to fix SL-32336 @@ -81,6 +84,9 @@ #include "lltrans.h" #include "llagentui.h" +// contains includes needed for WL estate settings +#include "llfloaterwater.h" + const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -287,6 +293,10 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) return; } + + // currently, region can send this message when its windlight settings change + LLEnvManager::instance().refreshFromStorage(LLEnvKey::SCOPE_REGION); + LLTabContainer* tab = floater->getChild("region_panels"); LLViewerRegion* region = gAgent.getRegion(); @@ -1144,9 +1154,32 @@ void LLPanelRegionTextureInfo::onClickDump(void* data) ///////////////////////////////////////////////////////////////////////////// // LLPanelRegionTerrainInfo ///////////////////////////////////////////////////////////////////////////// +// Initialize statics +LLPanelRegionTerrainInfo* LLPanelRegionTerrainInfo::sPanelRegionTerrainInfo = NULL; + +LLPanelRegionTerrainInfo* LLPanelRegionTerrainInfo::instance() +{ + if (!sPanelRegionTerrainInfo) + { + sPanelRegionTerrainInfo = new LLPanelRegionTerrainInfo(); + } + return sPanelRegionTerrainInfo; +} + +// virtual +void LLPanelRegionTerrainInfo::close(bool app_quitting) +{ + if (sPanelRegionTerrainInfo) + { + sPanelRegionTerrainInfo = NULL; + } +} + BOOL LLPanelRegionTerrainInfo::postBuild() { LLPanelRegionInfo::postBuild(); + + sPanelRegionTerrainInfo = this; // singleton instance pointer initCtrl("water_height_spin"); initCtrl("terrain_raise_spin"); @@ -1161,20 +1194,42 @@ BOOL LLPanelRegionTerrainInfo::postBuild() childSetAction("upload_raw_btn", onClickUploadRaw, this); childSetAction("bake_terrain_btn", onClickBakeTerrain, this); + // WL advanced buttons + childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, this); + childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, this); + childSetAction("EnvUseEstateTimeButton", onUseEstateTime, this); + + // Commit, cancel, and default + childSetAction("WLRegionApply", onCommitRegionWL, this); + childSetAction("WLRegionCancel", onCancelRegionWL, this); + childSetAction("WLRegionDefault", onSetRegionToDefaultWL, this); + return TRUE; } +F32 LLPanelRegionTerrainInfo::getSunHour() +{ + if (childIsEnabled("sun_hour_slider")) + { + return (F32)childGetValue("sun_hour_slider").asReal(); + } + return 0.f; +} + // virtual bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) { - llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl; - BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); setCtrlsEnabled(owner_or_god_or_manager); + + // Disable select children + LLPanelRegionTerrainInfo::instance()->setCommitControls(false); + LLPanelRegionTerrainInfo::instance()->setEnvControls(LLEnvManager::getInstance()->regionCapable()); getChildView("apply_btn")->setEnabled(FALSE); + LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); getChildView("download_raw_btn")->setEnabled(owner_or_god); getChildView("upload_raw_btn")->setEnabled(owner_or_god); @@ -1183,6 +1238,24 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) return LLPanelRegionInfo::refreshFromRegion(region); } +void LLPanelRegionTerrainInfo::setEnvControls(bool available) +{ + getChildView("EnvUseEstateTimeButton")->setVisible(available); + getChildView("EnvAdvancedSkyButton")->setVisible(available); + getChildView("EnvAdvancedWaterButton")->setVisible(available); + getChildView("WLRegionApply")->setVisible(available); + getChildView("WLRegionCancel")->setVisible(available); + getChildView("WLRegionDefault")->setVisible(available); + getChildView("wl_settings_unavailable")->setVisible(!available); +} + +void LLPanelRegionTerrainInfo::setCommitControls(bool available) +{ + getChildView("WLRegionApply")->setEnabled(available); + getChildView("WLRegionCancel")->setEnabled(available); + refresh(); +} + // virtual BOOL LLPanelRegionTerrainInfo::sendUpdate() { @@ -1320,9 +1393,70 @@ bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, con strings.push_back("bake"); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + return false; } +/////////////////////////////////////////////////////////////// +// Callbacks for WindLight additions to Region terrain panel + +void LLPanelRegionTerrainInfo::onOpenAdvancedSky(void* userData) +{ + LLFloaterWindLight::show(LLEnvKey::SCOPE_REGION); +} + +void LLPanelRegionTerrainInfo::onOpenAdvancedWater(void* userData) +{ + LLFloaterWater::show(LLEnvKey::SCOPE_REGION); +} + + +void LLPanelRegionTerrainInfo::onUseEstateTime(void* userData) +{ + if(LLFloaterWindLight::isOpen()) + { + // select the blank value in + LLFloaterWindLight* wl = LLFloaterWindLight::instance(); + LLComboBox* box = wl->getChild("WLPresetsCombo"); + box->selectByValue(""); + } + + LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LINDEN); +} + +/////////////////////////////////////////////////////// +// Advanced handling for WL region estate integration + +// Handle commit of WL settings to region +void LLPanelRegionTerrainInfo::onCommitRegionWL(void* userData) +{ + LLEnvManager::getInstance()->commitSettings(LLEnvKey::SCOPE_REGION); + LLEnvManager::getInstance()->maybeClearEditingScope(LLEnvKey::SCOPE_REGION, true, false); +} + +// Handle cancel of WL settings for region +void LLPanelRegionTerrainInfo::onCancelRegionWL(void* userData) +{ + LLEnvManager::getInstance()->maybeClearEditingScope(LLEnvKey::SCOPE_REGION, true, false); +} + +// Handle reversion of region WL settings to default +void LLPanelRegionTerrainInfo::onSetRegionToDefaultWL(void* userData) +{ + LLEnvManager::instance().resetInternalsToDefault(LLEnvKey::SCOPE_REGION); + LLEnvManager::instance().startEditingScope(LLEnvKey::SCOPE_REGION); +} + +void LLPanelRegionTerrainInfo::cancelChanges() +{ + LLFloaterWindLight::instance()->close(); + LLFloaterWater::instance()->close(); + LLFloaterDayCycle::instance()->close(); + + // disable commmit and cancel + LLPanelRegionTerrainInfo::instance()->setCommitControls(false); +} + ///////////////////////////////////////////////////////////////////////////// // LLPanelEstateInfo // @@ -1996,6 +2130,16 @@ bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) return rv; } +void LLFloaterRegionInfo::close(bool app_quitting) +{ + if(!app_quitting) + { + LLEnvManager::getInstance()->maybeClearEditingScope(true, false); + LLPanelRegionTerrainInfo::close(app_quitting); + } + LLFloater::close(app_quitting); +} + void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl) { if (checkRemovalButton(child_ctrl->getName())) diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 2393c74c45..2fdec5a944 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -57,6 +57,13 @@ class LLPanelRegionTerrainInfo; class LLPanelEstateInfo; class LLPanelEstateCovenant; +class LLEventTimer; +class LLEnvironmentSettings; +class LLWLParamManager; +class LLWaterParamManager; +class LLWLParamSet; +class LLWaterParamSet; + class LLFloaterRegionInfo : public LLFloater { friend class LLFloaterReg; @@ -221,19 +228,27 @@ protected: }; ///////////////////////////////////////////////////////////////////////////// - class LLPanelRegionTerrainInfo : public LLPanelRegionInfo { public: - LLPanelRegionTerrainInfo() - : LLPanelRegionInfo() {} + LLPanelRegionTerrainInfo() : LLPanelRegionInfo() {} ~LLPanelRegionTerrainInfo() {} - // LLPanel - virtual BOOL postBuild(); - virtual bool refreshFromRegion(LLViewerRegion* region); + static LLPanelRegionTerrainInfo* instance(); + virtual BOOL postBuild(); // LLPanel + static void close(bool app_quitting); + + F32 getSunHour(); + virtual bool refreshFromRegion(LLViewerRegion* region); // refresh local settings from region update from simulator + void setEnvControls(bool available); // Whether environment settings are available for this region + void setCommitControls(bool available); // Whether user can currently commit (whether they changed anything) + void cancelChanges(); // cancels changes, reverts local settings, and resyncs UI + + //static void onChangeAnything(LLUICtrl* ctrl, void* userData); // callback for any change, to enable commit button protected: + static LLPanelRegionTerrainInfo* sPanelRegionTerrainInfo; // static instance pointer for singleton + virtual BOOL sendUpdate(); void onChangeUseEstateTime(); @@ -244,6 +259,13 @@ protected: static void onClickUploadRaw(void*); static void onClickBakeTerrain(void*); bool callbackBakeTerrain(const LLSD& notification, const LLSD& response); + + static void onOpenAdvancedSky(void* userData); // open the advanced sky settings menu + static void onOpenAdvancedWater(void* userData); // open the advanced water settings menu + static void onUseEstateTime(void* userData); // sync time with the server + static void onCommitRegionWL(void* userData); // commit region information to server + static void onCancelRegionWL(void* userData); // cancel changes to region + static void onSetRegionToDefaultWL(void* userData); // revert region WL settings to default }; ///////////////////////////////////////////////////////////////////////////// @@ -332,6 +354,7 @@ public: // are ignored, so must disable UI. void setAccessAllowedEnabled(bool enable_agent, bool enable_group, bool enable_ban); + virtual void close(bool app_quitting = false); protected: virtual BOOL sendUpdate(); // confirmation dialog callback diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index be4b144f41..a443b788fb 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -59,6 +59,8 @@ #undef max std::set LLFloaterWater::sDefaultPresets; +LLEnvKey::EScope LLFloaterWater::sScope; +std::string LLFloaterWater::sOriginalTitle; LLFloaterWater::LLFloaterWater(const LLSD& key) : LLFloater(key) @@ -70,7 +72,7 @@ LLFloaterWater::~LLFloaterWater() } BOOL LLFloaterWater::postBuild() { - + sOriginalTitle=getTitle(); std::string def_water = getString("WLDefaultWaterNames"); // no editing or deleting of the blank string @@ -88,8 +90,8 @@ BOOL LLFloaterWater::postBuild() if(comboBox != NULL) { std::map::iterator mIt = - LLWaterParamManager::instance()->mParamList.begin(); - for(; mIt != LLWaterParamManager::instance()->mParamList.end(); mIt++) + LLWaterParamManager::getInstance()->mParamList.begin(); + for(; mIt != LLWaterParamManager::getInstance()->mParamList.end(); mIt++) { comboBox->add(mIt->first); } @@ -104,7 +106,7 @@ BOOL LLFloaterWater::postBuild() } void LLFloaterWater::initCallbacks(void) { - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); getChild("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterWater::onWaterFogColorMoved, this, _1, ¶m_mgr->mFogColor)); @@ -163,7 +165,7 @@ bool LLFloaterWater::newPromptCallback(const LLSD& notification, const LLSD& res if(option == 0) { LLComboBox* comboBox = getChild( "WaterPresetsCombo"); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); // add the current parameters to the list // see if it's there first @@ -195,7 +197,7 @@ void LLFloaterWater::syncMenu() { bool err; - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); LLWaterParamSet & current_params = param_mgr->mCurParams; @@ -262,9 +264,9 @@ void LLFloaterWater::onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vectorControl->mX = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // vector control callbacks @@ -274,9 +276,9 @@ void LLFloaterWater::onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vectorControl->mY = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // vector control callbacks @@ -286,9 +288,9 @@ void LLFloaterWater::onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vectorControl->mZ = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } @@ -299,9 +301,9 @@ void LLFloaterWater::onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vectorControl->mX = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // vector control callbacks @@ -311,9 +313,9 @@ void LLFloaterWater::onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vectorControl->mY = sldrCtrl->getValueF32(); - vectorControl->update(LLWaterParamManager::instance()->mCurParams); + vectorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } // color control callbacks @@ -335,9 +337,9 @@ void LLFloaterWater::onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* col getChild(name)->setValue(colorControl->mR); } - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* colorControl) @@ -359,9 +361,9 @@ void LLFloaterWater::onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* col } - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* colorControl) @@ -382,9 +384,9 @@ void LLFloaterWater::onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* col getChild(name)->setValue(colorControl->mB); } - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* colorControl) @@ -393,9 +395,9 @@ void LLFloaterWater::onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* col colorControl->mA = sldrCtrl->getValueF32(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + LLWaterParamManager::getInstance()->propagateParameters(); } @@ -454,8 +456,8 @@ void LLFloaterWater::onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* col } // now update the current parameters and send them to shaders - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl) @@ -464,10 +466,10 @@ void LLFloaterWater::onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl F32 val = sldrCtrl->getValueF32(); expFloatControl->mExp = val; - LLWaterParamManager::instance()->setDensitySliderValue(val); + LLWaterParamManager::getInstance()->setDensitySliderValue(val); - expFloatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl) @@ -476,23 +478,23 @@ void LLFloaterWater::onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floa floatControl->mX = sldrCtrl->getValueF32() / floatControl->mMult; - floatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + floatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* colorControl) { LLColorSwatchCtrl* swatch = static_cast(ctrl); *colorControl = swatch->get(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } void LLFloaterWater::onNormalMapPicked(LLUICtrl* ctrl) { LLTextureCtrl* textCtrl = static_cast(ctrl); LLUUID textID = textCtrl->getImageAssetID(); - LLWaterParamManager::instance()->setNormalMapID(textID); + LLWaterParamManager::getInstance()->setNormalMapID(textID); } void LLFloaterWater::onNewPreset() @@ -511,7 +513,7 @@ void LLFloaterWater::onSavePreset() return; } - LLWaterParamManager::instance()->mCurParams.mName = + LLWaterParamManager::getInstance()->mCurParams.mName = comboBox->getSelectedItemLabel(); // check to see if it's a default and shouldn't be overwritten @@ -532,7 +534,7 @@ bool LLFloaterWater::saveAlertCallback(const LLSD& notification, const LLSD& res // if they choose save, do it. Otherwise, don't do anything if(option == 0) { - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); param_mgr->setParamSet( param_mgr->mCurParams.mName, @@ -583,7 +585,7 @@ bool LLFloaterWater::deleteAlertCallback(const LLSD& notification, const LLSD& r return false; } - LLWaterParamManager::instance()->removeParamSet(name, true); + LLWaterParamManager::getInstance()->removeParamSet(name, true); // remove and choose another S32 new_index = combo_box->getCurrentIndex(); @@ -594,8 +596,8 @@ bool LLFloaterWater::deleteAlertCallback(const LLSD& notification, const LLSD& r { key_combo->remove(name); - // remove from slider, as well - day_cycle->deletePreset(name); + // water is not part of day cycles, yet + //day_cycle->deletePreset(name); } // pick the previously selected index after delete diff --git a/indra/newview/llfloaterwater.h b/indra/newview/llfloaterwater.h index e3db91e80d..57fb9745b1 100644 --- a/indra/newview/llfloaterwater.h +++ b/indra/newview/llfloaterwater.h @@ -101,6 +101,8 @@ public: private: static std::set sDefaultPresets; + static LLEnvKey::EScope sScope; + static std::string sOriginalTitle; }; diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index ae98b2cf99..960a552b3d 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -2,25 +2,31 @@ * @file llfloaterwindlight.cpp * @brief LLFloaterWindLight class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -31,11 +37,9 @@ #include "pipeline.h" #include "llsky.h" -#include "llfloaterreg.h" #include "llsliderctrl.h" #include "llmultislider.h" #include "llmultisliderctrl.h" -#include "llnotificationsutil.h" #include "llspinctrl.h" #include "llcheckboxctrl.h" #include "lluictrlfactory.h" @@ -54,48 +58,31 @@ #include "llwlparamset.h" #include "llwlparammanager.h" #include "llpostprocess.h" -#include "lltabcontainer.h" - #undef max -std::set LLFloaterWindLight::sDefaultPresets; +LLFloaterWindLight* LLFloaterWindLight::sWindLight = NULL; +std::set LLFloaterWindLight::sDefaultPresets; +LLEnvKey::EScope LLFloaterWindLight::sScope; +std::string LLFloaterWindLight::sOriginalTitle; static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -LLFloaterWindLight::LLFloaterWindLight(const LLSD& key) - : LLFloater(key) +LLFloaterWindLight::LLFloaterWindLight() : LLFloater(std::string("windlight floater")) { -} - -LLFloaterWindLight::~LLFloaterWindLight() -{ -} - -BOOL LLFloaterWindLight::postBuild() -{ - // add the list of presets - std::string def_days = getString("WLDefaultSkyNames"); - - // no editing or deleting of the blank string - sDefaultPresets.insert(""); - boost_tokenizer tokens(def_days, boost::char_separator(":")); - for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) - { - std::string tok(*token_iter); - sDefaultPresets.insert(tok); - } - + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_options.xml", NULL, FALSE); + sOriginalTitle = getTitle(); + // add the combo boxes LLComboBox* comboBox = getChild("WLPresetsCombo"); if(comboBox != NULL) { - - std::map::iterator mIt = - LLWLParamManager::instance()->mParamList.begin(); - for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) + + std::map::iterator mIt = + LLWLParamManager::getInstance()->mParamList.begin(); + for(; mIt != LLWLParamManager::getInstance()->mParamList.end(); mIt++) { - comboBox->add(mIt->first); + comboBox->add(mIt->first.toString(), mIt->first.toLLSD()); } // entry for when we're in estate time @@ -104,107 +91,167 @@ BOOL LLFloaterWindLight::postBuild() // set defaults on combo boxes comboBox->selectByValue(LLSD("Default")); } + + // add the list of presets + std::string def_days = getString("WLDefaultSkyNames"); + + // no editing or deleting of the blank string + LLWLParamKey blank("", LLEnvKey::SCOPE_LOCAL); + sDefaultPresets.insert(blank); + boost_tokenizer tokens(def_days, boost::char_separator(":")); + for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) + { + std::string tok(*token_iter); + LLWLParamKey key(tok, LLEnvKey::SCOPE_LOCAL); + sDefaultPresets.insert(key); + } + // load it up initCallbacks(); +} - syncMenu(); - - return TRUE; +LLFloaterWindLight::~LLFloaterWindLight() +{ } + void LLFloaterWindLight::initCallbacks(void) { - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + // help buttons + initHelpBtn("WLBlueHorizonHelp", "HelpBlueHorizon"); + initHelpBtn("WLHazeHorizonHelp", "HelpHazeHorizon"); + initHelpBtn("WLBlueDensityHelp", "HelpBlueDensity"); + initHelpBtn("WLHazeDensityHelp", "HelpHazeDensity"); + + initHelpBtn("WLDensityMultHelp", "HelpDensityMult"); + initHelpBtn("WLDistanceMultHelp", "HelpDistanceMult"); + initHelpBtn("WLMaxAltitudeHelp", "HelpMaxAltitude"); + + initHelpBtn("WLSunlightColorHelp", "HelpSunlightColor"); + initHelpBtn("WLAmbientHelp", "HelpSunAmbient"); + initHelpBtn("WLSunGlowHelp", "HelpSunGlow"); + initHelpBtn("WLTimeOfDayHelp", "HelpTimeOfDay"); + initHelpBtn("WLEastAngleHelp", "HelpEastAngle"); + + initHelpBtn("WLSceneGammaHelp", "HelpSceneGamma"); + initHelpBtn("WLStarBrightnessHelp", "HelpStarBrightness"); + + initHelpBtn("WLCloudColorHelp", "HelpCloudColor"); + initHelpBtn("WLCloudDetailHelp", "HelpCloudDetail"); + initHelpBtn("WLCloudDensityHelp", "HelpCloudDensity"); + initHelpBtn("WLCloudCoverageHelp", "HelpCloudCoverage"); + + initHelpBtn("WLCloudScaleHelp", "HelpCloudScale"); + initHelpBtn("WLCloudScrollXHelp", "HelpCloudScrollX"); + initHelpBtn("WLCloudScrollYHelp", "HelpCloudScrollY"); + + initHelpBtn("WLClassicCloudsHelp", "HelpClassicClouds"); + + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); // blue horizon - getChild("WLBlueHorizonR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mBlueHorizon)); - getChild("WLBlueHorizonG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mBlueHorizon)); - getChild("WLBlueHorizonB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mBlueHorizon)); - getChild("WLBlueHorizonI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, ¶m_mgr->mBlueHorizon)); + childSetCommitCallback("WLBlueHorizonR", onColorControlRMoved, ¶m_mgr->mBlueHorizon); + childSetCommitCallback("WLBlueHorizonG", onColorControlGMoved, ¶m_mgr->mBlueHorizon); + childSetCommitCallback("WLBlueHorizonB", onColorControlBMoved, ¶m_mgr->mBlueHorizon); + childSetCommitCallback("WLBlueHorizonI", onColorControlIMoved, ¶m_mgr->mBlueHorizon); // haze density, horizon, mult, and altitude - getChild("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mHazeDensity)); - getChild("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mHazeHorizon)); - getChild("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, ¶m_mgr->mDensityMult)); - getChild("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, ¶m_mgr->mMaxAlt)); + childSetCommitCallback("WLHazeDensity", onColorControlRMoved, ¶m_mgr->mHazeDensity); + childSetCommitCallback("WLHazeHorizon", onColorControlRMoved, ¶m_mgr->mHazeHorizon); + childSetCommitCallback("WLDensityMult", onFloatControlMoved, ¶m_mgr->mDensityMult); + childSetCommitCallback("WLMaxAltitude", onFloatControlMoved, ¶m_mgr->mMaxAlt); // blue density - getChild("WLBlueDensityR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mBlueDensity)); - getChild("WLBlueDensityG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mBlueDensity)); - getChild("WLBlueDensityB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mBlueDensity)); - getChild("WLBlueDensityI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, ¶m_mgr->mBlueDensity)); + childSetCommitCallback("WLBlueDensityR", onColorControlRMoved, ¶m_mgr->mBlueDensity); + childSetCommitCallback("WLBlueDensityG", onColorControlGMoved, ¶m_mgr->mBlueDensity); + childSetCommitCallback("WLBlueDensityB", onColorControlBMoved, ¶m_mgr->mBlueDensity); + childSetCommitCallback("WLBlueDensityI", onColorControlIMoved, ¶m_mgr->mBlueDensity); // Lighting // sunlight - getChild("WLSunlightR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mSunlight)); - getChild("WLSunlightG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mSunlight)); - getChild("WLSunlightB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mSunlight)); - getChild("WLSunlightI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, ¶m_mgr->mSunlight)); + childSetCommitCallback("WLSunlightR", onColorControlRMoved, ¶m_mgr->mSunlight); + childSetCommitCallback("WLSunlightG", onColorControlGMoved, ¶m_mgr->mSunlight); + childSetCommitCallback("WLSunlightB", onColorControlBMoved, ¶m_mgr->mSunlight); + childSetCommitCallback("WLSunlightI", onColorControlIMoved, ¶m_mgr->mSunlight); // glow - getChild("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onGlowRMoved, this, _1, ¶m_mgr->mGlow)); - getChild("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onGlowBMoved, this, _1, ¶m_mgr->mGlow)); + childSetCommitCallback("WLGlowR", onGlowRMoved, ¶m_mgr->mGlow); + childSetCommitCallback("WLGlowB", onGlowBMoved, ¶m_mgr->mGlow); // ambient - getChild("WLAmbientR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mAmbient)); - getChild("WLAmbientG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mAmbient)); - getChild("WLAmbientB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mAmbient)); - getChild("WLAmbientI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, ¶m_mgr->mAmbient)); + childSetCommitCallback("WLAmbientR", onColorControlRMoved, ¶m_mgr->mAmbient); + childSetCommitCallback("WLAmbientG", onColorControlGMoved, ¶m_mgr->mAmbient); + childSetCommitCallback("WLAmbientB", onColorControlBMoved, ¶m_mgr->mAmbient); + childSetCommitCallback("WLAmbientI", onColorControlIMoved, ¶m_mgr->mAmbient); // time of day - getChild("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterWindLight::onSunMoved, this, _1, ¶m_mgr->mLightnorm)); - getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterWindLight::onSunMoved, this, _1, ¶m_mgr->mLightnorm)); + childSetCommitCallback("WLSunAngle", onSunMoved, ¶m_mgr->mLightnorm); + childSetCommitCallback("WLEastAngle", onSunMoved, ¶m_mgr->mLightnorm); // Clouds // Cloud Color - getChild("WLCloudColorR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mCloudColor)); - getChild("WLCloudColorG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mCloudColor)); - getChild("WLCloudColorB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mCloudColor)); - getChild("WLCloudColorI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, ¶m_mgr->mCloudColor)); + childSetCommitCallback("WLCloudColorR", onColorControlRMoved, ¶m_mgr->mCloudColor); + childSetCommitCallback("WLCloudColorG", onColorControlGMoved, ¶m_mgr->mCloudColor); + childSetCommitCallback("WLCloudColorB", onColorControlBMoved, ¶m_mgr->mCloudColor); + childSetCommitCallback("WLCloudColorI", onColorControlIMoved, ¶m_mgr->mCloudColor); // Cloud - getChild("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mCloudMain)); - getChild("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mCloudMain)); - getChild("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mCloudMain)); + childSetCommitCallback("WLCloudX", onColorControlRMoved, ¶m_mgr->mCloudMain); + childSetCommitCallback("WLCloudY", onColorControlGMoved, ¶m_mgr->mCloudMain); + childSetCommitCallback("WLCloudDensity", onColorControlBMoved, ¶m_mgr->mCloudMain); // Cloud Detail - getChild("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, ¶m_mgr->mCloudDetail)); - getChild("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, ¶m_mgr->mCloudDetail)); - getChild("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, ¶m_mgr->mCloudDetail)); + childSetCommitCallback("WLCloudDetailX", onColorControlRMoved, ¶m_mgr->mCloudDetail); + childSetCommitCallback("WLCloudDetailY", onColorControlGMoved, ¶m_mgr->mCloudDetail); + childSetCommitCallback("WLCloudDetailDensity", onColorControlBMoved, ¶m_mgr->mCloudDetail); // Cloud extras - getChild("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, ¶m_mgr->mCloudCoverage)); - getChild("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, ¶m_mgr->mCloudScale)); - getChild("WLCloudLockX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollXToggled, this, _1)); - getChild("WLCloudLockY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollYToggled, this, _1)); - getChild("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollXMoved, this, _1)); - getChild("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollYMoved, this, _1)); - getChild("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, ¶m_mgr->mDistanceMult)); - getChild("DrawClassicClouds")->setCommitCallback(boost::bind(LLSavedSettingsGlue::setBOOL, _1, "SkyUseClassicClouds")); + childSetCommitCallback("WLCloudCoverage", onFloatControlMoved, ¶m_mgr->mCloudCoverage); + childSetCommitCallback("WLCloudScale", onFloatControlMoved, ¶m_mgr->mCloudScale); + childSetCommitCallback("WLCloudLockX", onCloudScrollXToggled, NULL); + childSetCommitCallback("WLCloudLockY", onCloudScrollYToggled, NULL); + childSetCommitCallback("WLCloudScrollX", onCloudScrollXMoved, NULL); + childSetCommitCallback("WLCloudScrollY", onCloudScrollYMoved, NULL); + childSetCommitCallback("WLDistanceMult", onFloatControlMoved, ¶m_mgr->mDistanceMult); + childSetCommitCallback("DrawClassicClouds", LLSavedSettingsGlue::setBOOL, (void*)"SkyUseClassicClouds"); // WL Top - getChild("WLDayCycleMenuButton")->setCommitCallback(boost::bind(&LLFloaterWindLight::onOpenDayCycle, this)); + childSetAction("WLDayCycleMenuButton", onOpenDayCycle, NULL); // Load/save LLComboBox* comboBox = getChild("WLPresetsCombo"); //childSetAction("WLLoadPreset", onLoadPreset, comboBox); - getChild("WLNewPreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onNewPreset, this)); - getChild("WLSavePreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onSavePreset, this)); - getChild("WLDeletePreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onDeletePreset, this)); + childSetAction("WLNewPreset", onNewPreset, comboBox); + childSetAction("WLSavePreset", onSavePreset, comboBox); + childSetAction("WLDeletePreset", onDeletePreset, comboBox); - comboBox->setCommitCallback(boost::bind(&LLFloaterWindLight::onChangePresetName, this, _1)); + comboBox->setCommitCallback(onChangePresetName); // Dome - getChild("WLGamma")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, ¶m_mgr->mWLGamma)); - getChild("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterWindLight::onStarAlphaMoved, this, _1)); + childSetCommitCallback("WLGamma", onFloatControlMoved, ¶m_mgr->mWLGamma); + childSetCommitCallback("WLStarAlpha", onStarAlphaMoved, NULL); +} + +void LLFloaterWindLight::onClickHelp(void* data) +{ + LLFloaterWindLight* self = LLFloaterWindLight::instance(); + + const std::string xml_alert = *(std::string*)data; + LLNotifications::instance().add(self->contextualNotification(xml_alert)); +} + +void LLFloaterWindLight::initHelpBtn(const std::string& name, const std::string& xml_alert) +{ + childSetAction(name, onClickHelp, new std::string(xml_alert)); } bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& response) { std::string text = response["message"].asString(); - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + LLWLParamKey newKey(text, LLEnvKey::SCOPE_LOCAL); + S32 option = LLNotification::getSelectedOption(notification, response); if(text == "") { @@ -212,26 +259,29 @@ bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& } if(option == 0) { - LLComboBox* comboBox = getChild("WLPresetsCombo"); + LLComboBox* comboBox = sWindLight->getChild( + "WLPresetsCombo"); - LLFloaterDayCycle* day_cycle = LLFloaterReg::findTypedInstance("env_day_cycle"); + LLFloaterDayCycle* sDayCycle = NULL; LLComboBox* keyCombo = NULL; - if(day_cycle) + if(LLFloaterDayCycle::isOpen()) { - keyCombo = day_cycle->getChild("WLKeyPresets"); + sDayCycle = LLFloaterDayCycle::instance(); + keyCombo = sDayCycle->getChild( + "WLKeyPresets"); } // add the current parameters to the list // see if it's there first - std::map::iterator mIt = - LLWLParamManager::instance()->mParamList.find(text); + std::map::iterator mIt = + LLWLParamManager::getInstance()->mParamList.find(newKey); // if not there, add a new one - if(mIt == LLWLParamManager::instance()->mParamList.end()) + if(mIt == LLWLParamManager::getInstance()->mParamList.end()) { - LLWLParamManager::instance()->addParamSet(text, - LLWLParamManager::instance()->mCurParams); - comboBox->add(text); + LLWLParamManager::getInstance()->addParamSet(newKey, + LLWLParamManager::getInstance()->mCurParams); + comboBox->add(newKey.toString(), newKey.toLLSD()); comboBox->sortByName(); // add a blank to the bottom @@ -243,18 +293,18 @@ bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& comboBox->add(LLStringUtil::null); comboBox->setSelectedByValue(text, true); - if(keyCombo) + if(LLFloaterDayCycle::isOpen()) { keyCombo->add(text); keyCombo->sortByName(); } - LLWLParamManager::instance()->savePreset(text); + LLWLParamManager::getInstance()->savePreset(newKey); // otherwise, send a message to the user } else { - LLNotificationsUtil::add("ExistsSkyPresetAlert"); + LLNotifications::instance().add("ExistsSkyPresetAlert"); } } return false; @@ -264,38 +314,38 @@ void LLFloaterWindLight::syncMenu() { bool err; - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); LLWLParamSet& currentParams = param_mgr->mCurParams; //std::map & currentParams = param_mgr->mCurParams.mParamValues; // blue horizon param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.mName, err); - getChild("WLBlueHorizonR")->setValue(param_mgr->mBlueHorizon.r / 2.0); - getChild("WLBlueHorizonG")->setValue(param_mgr->mBlueHorizon.g / 2.0); - getChild("WLBlueHorizonB")->setValue(param_mgr->mBlueHorizon.b / 2.0); - getChild("WLBlueHorizonI")->setValue( + childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0); + childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0); + childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0); + childSetValue("WLBlueHorizonI", std::max(param_mgr->mBlueHorizon.r / 2.0, std::max(param_mgr->mBlueHorizon.g / 2.0, param_mgr->mBlueHorizon.b / 2.0))); // haze density, horizon, mult, and altitude param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.mName, err); - getChild("WLHazeDensity")->setValue(param_mgr->mHazeDensity.r); + childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r); param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.mName, err); - getChild("WLHazeHorizon")->setValue(param_mgr->mHazeHorizon.r); + childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r); param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.mName, err); - getChild("WLDensityMult")->setValue(param_mgr->mDensityMult.x * + childSetValue("WLDensityMult", param_mgr->mDensityMult.x * param_mgr->mDensityMult.mult); param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.mName, err); - getChild("WLMaxAltitude")->setValue(param_mgr->mMaxAlt.x); + childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x); // blue density param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.mName, err); - getChild("WLBlueDensityR")->setValue(param_mgr->mBlueDensity.r / 2.0); - getChild("WLBlueDensityG")->setValue(param_mgr->mBlueDensity.g / 2.0); - getChild("WLBlueDensityB")->setValue(param_mgr->mBlueDensity.b / 2.0); - getChild("WLBlueDensityI")->setValue( + childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0); + childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0); + childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0); + childSetValue("WLBlueDensityI", std::max(param_mgr->mBlueDensity.r / 2.0, std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0))); @@ -303,107 +353,161 @@ void LLFloaterWindLight::syncMenu() // sunlight param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.mName, err); - getChild("WLSunlightR")->setValue(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE); - getChild("WLSunlightG")->setValue(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE); - getChild("WLSunlightB")->setValue(param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE); - getChild("WLSunlightI")->setValue( + childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLSunlightI", std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE, std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE))); // glow param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.mName, err); - getChild("WLGlowR")->setValue(2 - param_mgr->mGlow.r / 20.0f); - getChild("WLGlowB")->setValue(-param_mgr->mGlow.b / 5.0f); + childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f); + childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f); // ambient param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.mName, err); - getChild("WLAmbientR")->setValue(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE); - getChild("WLAmbientG")->setValue(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE); - getChild("WLAmbientB")->setValue(param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE); - getChild("WLAmbientI")->setValue( + childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLAmbientI", std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE, std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE))); - getChild("WLSunAngle")->setValue(param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); - getChild("WLEastAngle")->setValue(param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); + childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); + childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); // Clouds // Cloud Color param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.mName, err); - getChild("WLCloudColorR")->setValue(param_mgr->mCloudColor.r); - getChild("WLCloudColorG")->setValue(param_mgr->mCloudColor.g); - getChild("WLCloudColorB")->setValue(param_mgr->mCloudColor.b); - getChild("WLCloudColorI")->setValue( + childSetValue("WLCloudColorR", param_mgr->mCloudColor.r); + childSetValue("WLCloudColorG", param_mgr->mCloudColor.g); + childSetValue("WLCloudColorB", param_mgr->mCloudColor.b); + childSetValue("WLCloudColorI", std::max(param_mgr->mCloudColor.r, std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b))); // Cloud param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.mName, err); - getChild("WLCloudX")->setValue(param_mgr->mCloudMain.r); - getChild("WLCloudY")->setValue(param_mgr->mCloudMain.g); - getChild("WLCloudDensity")->setValue(param_mgr->mCloudMain.b); + childSetValue("WLCloudX", param_mgr->mCloudMain.r); + childSetValue("WLCloudY", param_mgr->mCloudMain.g); + childSetValue("WLCloudDensity", param_mgr->mCloudMain.b); // Cloud Detail param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.mName, err); - getChild("WLCloudDetailX")->setValue(param_mgr->mCloudDetail.r); - getChild("WLCloudDetailY")->setValue(param_mgr->mCloudDetail.g); - getChild("WLCloudDetailDensity")->setValue(param_mgr->mCloudDetail.b); + childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r); + childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g); + childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b); // Cloud extras param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.mName, err); param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.mName, err); - getChild("WLCloudCoverage")->setValue(param_mgr->mCloudCoverage.x); - getChild("WLCloudScale")->setValue(param_mgr->mCloudScale.x); + childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x); + childSetValue("WLCloudScale", param_mgr->mCloudScale.x); // cloud scrolling bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX(); bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); - getChild("WLCloudLockX")->setValue(lockX); - getChild("WLCloudLockY")->setValue(lockY); - getChild("DrawClassicClouds")->setValue(gSavedSettings.getBOOL("SkyUseClassicClouds")); + childSetValue("WLCloudLockX", lockX); + childSetValue("WLCloudLockY", lockY); + childSetValue("DrawClassicClouds", gSavedSettings.getBOOL("SkyUseClassicClouds")); // disable if locked, enable if not if(lockX) { - getChildView("WLCloudScrollX")->setEnabled(FALSE); + childDisable("WLCloudScrollX"); } else { - getChildView("WLCloudScrollX")->setEnabled(TRUE); + childEnable("WLCloudScrollX"); } if(lockY) { - getChildView("WLCloudScrollY")->setEnabled(FALSE); + childDisable("WLCloudScrollY"); } else { - getChildView("WLCloudScrollY")->setEnabled(TRUE); + childEnable("WLCloudScrollY"); } // *HACK cloud scrolling is off my an additive of 10 - getChild("WLCloudScrollX")->setValue(param_mgr->mCurParams.getCloudScrollX() - 10.0f); - getChild("WLCloudScrollY")->setValue(param_mgr->mCurParams.getCloudScrollY() - 10.0f); + childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f); + childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f); param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.mName, err); - getChild("WLDistanceMult")->setValue(param_mgr->mDistanceMult.x); + childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x); // Tweak extras param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.mName, err); - getChild("WLGamma")->setValue(param_mgr->mWLGamma.x); + childSetValue("WLGamma", param_mgr->mWLGamma.x); - getChild("WLStarAlpha")->setValue(param_mgr->mCurParams.getStarBrightness()); + childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); +} - LLTabContainer* tab = getChild("WindLight Tabs"); - LLPanel* panel = getChild("Scattering"); - tab->enableTabButton(tab->getIndexForPanel(panel), gSavedSettings.getBOOL("RenderDeferredGI")); +// static +LLFloaterWindLight* LLFloaterWindLight::instance() +{ + if (!sWindLight) + { + sWindLight = new LLFloaterWindLight(); + } + return sWindLight; +} +void LLFloaterWindLight::show(LLEnvKey::EScope scope) +{ + LLFloaterWindLight* windLight = instance(); + if(scope != sScope && ((LLView*)windLight)->getVisible()) + { + LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD()); + return; + } + sScope = scope; + std::string scope_str = ""; + switch(sScope) + { + case LLEnvKey::SCOPE_LOCAL: + scope_str = LLTrans::getString("LocalSettings"); + break; + case LLEnvKey::SCOPE_REGION: + scope_str = LLTrans::getString("RegionSettings"); + break; + } + std::string title = sOriginalTitle + " (" + scope_str + ")"; + windLight->setTitle(title); + windLight->syncMenu(); + + LLEnvManager::instance().startEditingScope(scope); + + // comment in if you want the menu to rebuild each time + //LLUICtrlFactory::getInstance()->buildFloater(windLight, "floater_windlight_options.xml"); + //windLight->initCallbacks(); + + windLight->open(); } +bool LLFloaterWindLight::isOpen() +{ + if (sWindLight != NULL) { + return true; + } + return false; +} + +// virtual +void LLFloaterWindLight::onClose(bool app_quitting) +{ + if (sWindLight) + { + sWindLight->setVisible(FALSE); + } +} // color control callbacks -void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLColorControl * colorControl = static_cast(userData); colorControl->r = sldrCtrl->getValueF32(); if(colorControl->isSunOrAmbientColor) { @@ -421,24 +525,25 @@ void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, WLColorControl* co name.append("I"); if(colorControl->isSunOrAmbientColor) { - getChild(name)->setValue(colorControl->r / 3); + sWindLight->childSetValue(name, colorControl->r / 3); } else if(colorControl->isBlueHorizonOrDensity) { - getChild(name)->setValue(colorControl->r / 2); + sWindLight->childSetValue(name, colorControl->r / 2); } else { - getChild(name)->setValue(colorControl->r); + sWindLight->childSetValue(name, colorControl->r); } } - colorControl->update(LLWLParamManager::instance()->mCurParams); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } -void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLColorControl * colorControl = static_cast(userData); colorControl->g = sldrCtrl->getValueF32(); if(colorControl->isSunOrAmbientColor) { @@ -456,24 +561,25 @@ void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, WLColorControl* co name.append("I"); if(colorControl->isSunOrAmbientColor) { - getChild(name)->setValue(colorControl->g / 3); + sWindLight->childSetValue(name, colorControl->g / 3); } else if(colorControl->isBlueHorizonOrDensity) { - getChild(name)->setValue(colorControl->g / 2); + sWindLight->childSetValue(name, colorControl->g / 2); } else { - getChild(name)->setValue(colorControl->g); + sWindLight->childSetValue(name, colorControl->g); } } - colorControl->update(LLWLParamManager::instance()->mCurParams); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } -void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLColorControl * colorControl = static_cast(userData); colorControl->b = sldrCtrl->getValueF32(); if(colorControl->isSunOrAmbientColor) { @@ -491,24 +597,25 @@ void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, WLColorControl* co name.append("I"); if(colorControl->isSunOrAmbientColor) { - getChild(name)->setValue(colorControl->b / 3); + sWindLight->childSetValue(name, colorControl->b / 3); } else if(colorControl->isBlueHorizonOrDensity) { - getChild(name)->setValue(colorControl->b / 2); + sWindLight->childSetValue(name, colorControl->b / 2); } else { - getChild(name)->setValue(colorControl->b); + sWindLight->childSetValue(name, colorControl->b); } } - colorControl->update(LLWLParamManager::instance()->mCurParams); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + LLWLParamManager::getInstance()->propagateParameters(); } -void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLColorControl * colorControl = static_cast(userData); colorControl->i = sldrCtrl->getValueF32(); @@ -565,84 +672,100 @@ void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, WLColorControl* co // divide sun color vals by three if(colorControl->isSunOrAmbientColor) { - getChild(rName)->setValue(colorControl->r/3); - getChild(gName)->setValue(colorControl->g/3); - getChild(bName)->setValue(colorControl->b/3); + sWindLight->childSetValue(rName, colorControl->r/3); + sWindLight->childSetValue(gName, colorControl->g/3); + sWindLight->childSetValue(bName, colorControl->b/3); } else if(colorControl->isBlueHorizonOrDensity) { - getChild(rName)->setValue(colorControl->r/2); - getChild(gName)->setValue(colorControl->g/2); - getChild(bName)->setValue(colorControl->b/2); + sWindLight->childSetValue(rName, colorControl->r/2); + sWindLight->childSetValue(gName, colorControl->g/2); + sWindLight->childSetValue(bName, colorControl->b/2); } else { // set the sliders to the new vals - getChild(rName)->setValue(colorControl->r); - getChild(gName)->setValue(colorControl->g); - getChild(bName)->setValue(colorControl->b); + sWindLight->childSetValue(rName, colorControl->r); + sWindLight->childSetValue(gName, colorControl->g); + sWindLight->childSetValue(bName, colorControl->b); } } // now update the current parameters and send them to shaders - colorControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } /// GLOW SPECIFIC CODE -void LLFloaterWindLight::onGlowRMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onGlowRMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLColorControl * colorControl = static_cast(userData); // scaled by 20 colorControl->r = (2 - sldrCtrl->getValueF32()) * 20; - colorControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } /// \NOTE that we want NEGATIVE (-) B -void LLFloaterWindLight::onGlowBMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onGlowBMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLColorControl * colorControl = static_cast(userData); /// \NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big colorControl->b = -sldrCtrl->getValueF32() * 5; - colorControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + colorControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); } -void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl) +void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); + WLFloatControl * floatControl = static_cast(userData); floatControl->x = sldrCtrl->getValueF32() / floatControl->mult; - floatControl->update(LLWLParamManager::instance()->mCurParams); - LLWLParamManager::instance()->propagateParameters(); + floatControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); +} + +void LLFloaterWindLight::onBoolToggle(LLUICtrl* ctrl, void* userData) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLCheckBoxCtrl* cbCtrl = static_cast(ctrl); + + bool value = cbCtrl->get(); + (*(static_cast(userData))) = value; } + // Lighting callbacks // time of day -void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, WLColorControl* colorControl) +void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sunSldr = getChild("WLSunAngle"); - LLSliderCtrl* eastSldr = getChild("WLEastAngle"); + LLSliderCtrl* sunSldr = sWindLight->getChild("WLSunAngle"); + LLSliderCtrl* eastSldr = sWindLight->getChild("WLEastAngle"); + WLColorControl * colorControl = static_cast(userData); + // get the two angles - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); param_mgr->mCurParams.setSunAngle(F_TWO_PI * sunSldr->getValueF32()); param_mgr->mCurParams.setEastAngle(F_TWO_PI * eastSldr->getValueF32()); @@ -659,24 +782,35 @@ void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, WLColorControl* colorControl param_mgr->propagateParameters(); } -void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl) +void LLFloaterWindLight::onFloatTweakMoved(LLUICtrl* ctrl, void* userData) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldrCtrl = static_cast(ctrl); + F32 * tweak = static_cast(userData); + + (*tweak) = sldrCtrl->getValueF32(); + LLWLParamManager::getInstance()->propagateParameters(); +} + +void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); - LLWLParamManager::instance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32()); + LLWLParamManager::getInstance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32()); } -void LLFloaterWindLight::onNewPreset() +void LLFloaterWindLight::onNewPreset(void* userData) { - LLNotificationsUtil::add("NewSkyPreset", LLSD(), LLSD(), boost::bind(&LLFloaterWindLight::newPromptCallback, this, _1, _2)); + LLNotifications::instance().add("NewSkyPreset", LLSD(), LLSD(), newPromptCallback); } -void LLFloaterWindLight::onSavePreset() +void LLFloaterWindLight::onSavePreset(void* userData) { // get the name - LLComboBox* comboBox = getChild( + LLComboBox* comboBox = sWindLight->getChild( "WLPresetsCombo"); // don't save the empty name @@ -686,90 +820,98 @@ void LLFloaterWindLight::onSavePreset() } // check to see if it's a default and shouldn't be overwritten - std::set::iterator sIt = sDefaultPresets.find( - comboBox->getSelectedItemLabel()); + std::set::iterator sIt = sDefaultPresets.find( + LLWLParamKey(comboBox->getSelectedValue())); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) { - LLNotificationsUtil::add("WLNoEditDefault"); + LLNotifications::instance().add("WLNoEditDefault"); return; } - LLWLParamManager::instance()->mCurParams.mName = + LLWLParamManager::getInstance()->mCurParams.mName = comboBox->getSelectedItemLabel(); - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterWindLight::saveAlertCallback, this, _1, _2)); + LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + S32 option = LLNotification::getSelectedOption(notification, response); // if they choose save, do it. Otherwise, don't do anything if(option == 0) { - LLWLParamManager * param_mgr = LLWLParamManager::instance(); + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); + + // we should only "save" local presets; those with other scopes should be "save as" + LLWLParamKey key(param_mgr->mCurParams.mName, LLEnvKey::SCOPE_LOCAL); - param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); + param_mgr->setParamSet(key, param_mgr->mCurParams); // comment this back in to save to file - param_mgr->savePreset(param_mgr->mCurParams.mName); + param_mgr->savePreset(key); } return false; } -void LLFloaterWindLight::onDeletePreset() +void LLFloaterWindLight::onDeletePreset(void* userData) { - LLComboBox* combo_box = getChild( + LLComboBox* combo_box = sWindLight->getChild( "WLPresetsCombo"); - if(combo_box->getSelectedValue().asString() == "") + if(combo_box->getSelectedValue().isUndefined()) { return; } LLSD args; - args["SKY"] = combo_box->getSelectedValue().asString(); - LLNotificationsUtil::add("WLDeletePresetAlert", args, LLSD(), - boost::bind(&LLFloaterWindLight::deleteAlertCallback, this, _1, _2)); + args["SKY"] = combo_box->getSelectedValue()[0].asString(); + LLNotifications::instance().add("WLDeletePresetAlert", args, LLSD(), + boost::bind(&LLFloaterWindLight::deleteAlertCallback, sWindLight, _1, _2)); } bool LLFloaterWindLight::deleteAlertCallback(const LLSD& notification, const LLSD& response) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + S32 option = LLNotification::getSelectedOption(notification, response); // if they choose delete, do it. Otherwise, don't do anything if(option == 0) { - LLComboBox* combo_box = getChild("WLPresetsCombo"); - LLFloaterDayCycle* day_cycle = LLFloaterReg::findTypedInstance("env_day_cycle"); + LLComboBox* combo_box = getChild( + "WLPresetsCombo"); + LLFloaterDayCycle* day_cycle = NULL; LLComboBox* key_combo = NULL; + LLMultiSliderCtrl* mult_sldr = NULL; - if (day_cycle) + if(LLFloaterDayCycle::isOpen()) { - key_combo = day_cycle->getChild("WLKeyPresets"); + day_cycle = LLFloaterDayCycle::instance(); + key_combo = day_cycle->getChild( + "WLKeyPresets"); + mult_sldr = day_cycle->getChild("WLDayCycleKeys"); } - std::string name(combo_box->getSelectedValue().asString()); + LLWLParamKey key(combo_box->getSelectedValue()); // check to see if it's a default and shouldn't be deleted - std::set::iterator sIt = sDefaultPresets.find(name); + std::set::iterator sIt = sDefaultPresets.find(key); if(sIt != sDefaultPresets.end()) { - LLNotificationsUtil::add("WLNoEditDefault"); + LLNotifications::instance().add("WLNoEditDefault"); return false; } - LLWLParamManager::instance()->removeParamSet(name, true); + LLWLParamManager::getInstance()->removeParamSet(key, true); // remove and choose another S32 new_index = combo_box->getCurrentIndex(); - combo_box->remove(name); + combo_box->remove(key.toString()); if(key_combo != NULL) { - key_combo->remove(name); + key_combo->remove(key.toString()); // remove from slider, as well - day_cycle->deletePreset(name); + day_cycle->deletePreset(key); } // pick the previously selected index after delete @@ -787,53 +929,56 @@ bool LLFloaterWindLight::deleteAlertCallback(const LLSD& notification, const LLS } -void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl) +void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl, void * userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); - std::string data = ctrl->getValue().asString(); - if(!data.empty()) + LLComboBox * combo_box = static_cast(ctrl); + + if(combo_box->getSimple() == "") { - LLWLParamManager::instance()->loadPreset( data); - syncMenu(); + return; } + + LLWLParamManager::getInstance()->loadPreset(LLWLParamKey(combo_box->getSelectedValue())); + sWindLight->syncMenu(); } -void LLFloaterWindLight::onOpenDayCycle() +void LLFloaterWindLight::onOpenDayCycle(void* userData) { - LLFloaterReg::showInstance("env_day_cycle"); + LLFloaterDayCycle::show(sScope); } // Clouds -void LLFloaterWindLight::onCloudScrollXMoved(LLUICtrl* ctrl) +void LLFloaterWindLight::onCloudScrollXMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::instance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f); + LLWLParamManager::getInstance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f); } -void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl) +void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldrCtrl = static_cast(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::instance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f); + LLWLParamManager::getInstance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f); } -void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl) +void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLCheckBoxCtrl* cbCtrl = static_cast(ctrl); bool lock = cbCtrl->get(); - LLWLParamManager::instance()->mCurParams.setEnableCloudScrollX(!lock); + LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollX(!lock); - LLSliderCtrl* sldr = getChild( + LLSliderCtrl* sldr = sWindLight->getChild( "WLCloudScrollX"); if(cbCtrl->get()) @@ -847,15 +992,15 @@ void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl) } -void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl) +void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl, void* userData) { - deactivateAnimator(); + LLWLParamManager::getInstance()->mAnimator.deactivate(); LLCheckBoxCtrl* cbCtrl = static_cast(ctrl); bool lock = cbCtrl->get(); - LLWLParamManager::instance()->mCurParams.setEnableCloudScrollY(!lock); + LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollY(!lock); - LLSliderCtrl* sldr = getChild( + LLSliderCtrl* sldr = sWindLight->getChild( "WLCloudScrollY"); if(cbCtrl->get()) @@ -867,9 +1012,3 @@ void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl) sldr->setEnabled(true); } } - -void LLFloaterWindLight::deactivateAnimator() -{ - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; -} diff --git a/indra/newview/llfloaterwindlight.h b/indra/newview/llfloaterwindlight.h index b43edc2c11..c0fea2558c 100644 --- a/indra/newview/llfloaterwindlight.h +++ b/indra/newview/llfloaterwindlight.h @@ -2,25 +2,31 @@ * @file llfloaterwindlight.h * @brief LLFloaterWindLight class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -35,77 +41,98 @@ #include #include "llwlparamset.h" +#include "llwlparammanager.h" struct WLColorControl; struct WLFloatControl; - /// Menuing system for all of windlight's functionality class LLFloaterWindLight : public LLFloater { public: - - LLFloaterWindLight(const LLSD& key); + LLFloaterWindLight(); virtual ~LLFloaterWindLight(); - /*virtual*/ BOOL postBuild(); + /// initialize all void initCallbacks(void); - bool newPromptCallback(const LLSD& notification, const LLSD& response); + /// one and one instance only + static LLFloaterWindLight* instance(); + + // help button stuff + static void onClickHelp(void* data); + void initHelpBtn(const std::string& name, const std::string& xml_alert); + + static bool newPromptCallback(const LLSD& notification, const LLSD& response); /// general purpose callbacks for dealing with color controllers - void onColorControlRMoved(LLUICtrl* ctrl, WLColorControl* userData); - void onColorControlGMoved(LLUICtrl* ctrl, WLColorControl* userData); - void onColorControlBMoved(LLUICtrl* ctrl, WLColorControl* userData); - void onColorControlIMoved(LLUICtrl* ctrl, WLColorControl* userData); - void onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* userData); + static void onColorControlRMoved(LLUICtrl* ctrl, void* userData); + static void onColorControlGMoved(LLUICtrl* ctrl, void* userData); + static void onColorControlBMoved(LLUICtrl* ctrl, void* userData); + static void onColorControlIMoved(LLUICtrl* ctrl, void* userData); + static void onFloatControlMoved(LLUICtrl* ctrl, void* userData); + static void onBoolToggle(LLUICtrl* ctrl, void* userData); /// lighting callbacks for glow - void onGlowRMoved(LLUICtrl* ctrl, WLColorControl* userData); + static void onGlowRMoved(LLUICtrl* ctrl, void* userData); //static void onGlowGMoved(LLUICtrl* ctrl, void* userData); - void onGlowBMoved(LLUICtrl* ctrl, WLColorControl* userData); + static void onGlowBMoved(LLUICtrl* ctrl, void* userData); /// lighting callbacks for sun - void onSunMoved(LLUICtrl* ctrl, WLColorControl* userData); + static void onSunMoved(LLUICtrl* ctrl, void* userData); + + /// handle if float is changed + static void onFloatTweakMoved(LLUICtrl* ctrl, void* userData); /// for handling when the star slider is moved to adjust the alpha - void onStarAlphaMoved(LLUICtrl* ctrl); + static void onStarAlphaMoved(LLUICtrl* ctrl, void* userData); /// when user hits the load preset button - void onNewPreset(); + static void onNewPreset(void* userData); /// when user hits the save preset button - void onSavePreset(); + static void onSavePreset(void* userData); /// prompts a user when overwriting a preset - bool saveAlertCallback(const LLSD& notification, const LLSD& response); + static bool saveAlertCallback(const LLSD& notification, const LLSD& response); /// when user hits the save preset button - void onDeletePreset(); + static void onDeletePreset(void* userData); /// prompts a user when overwriting a preset bool deleteAlertCallback(const LLSD& notification, const LLSD& response); /// what to do when you change the preset name - void onChangePresetName(LLUICtrl* ctrl); + static void onChangePresetName(LLUICtrl* ctrl, void* userData); /// when user hits the save preset button - void onOpenDayCycle(); + static void onOpenDayCycle(void* userData); /// handle cloud scrolling - void onCloudScrollXMoved(LLUICtrl* ctrl); - void onCloudScrollYMoved(LLUICtrl* ctrl); - void onCloudScrollXToggled(LLUICtrl* ctrl); - void onCloudScrollYToggled(LLUICtrl* ctrl); + static void onCloudScrollXMoved(LLUICtrl* ctrl, void* userData); + static void onCloudScrollYMoved(LLUICtrl* ctrl, void* userData); + static void onCloudScrollXToggled(LLUICtrl* ctrl, void* userData); + static void onCloudScrollYToggled(LLUICtrl* ctrl, void* userData); + + //// menu management + + /// show off our menu + static void show(LLEnvKey::EScope scope = LLEnvKey::SCOPE_LOCAL); + + /// return if the menu exists or not + static bool isOpen(); + + /// stuff to do on exit + virtual void onClose(bool app_quitting); /// sync up sliders with parameters void syncMenu(); - /// turn off animated skies - static void deactivateAnimator(); - private: - static std::set sDefaultPresets; + static LLFloaterWindLight* sWindLight; // one instance on the inside + static std::set sDefaultPresets; + static LLEnvKey::EScope sScope; + static std::string sOriginalTitle; }; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c56cacd12b..7fa78ab386 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1153,8 +1153,6 @@ bool idle_startup() // init the shader managers LLPostProcess::initClass(); - LLWLParamManager::initClass(); - LLWaterParamManager::initClass(); LLViewerObject::initVOClasses(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 916cbe2267..5b0cf72ac5 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -178,8 +178,8 @@ void display_update_camera() gViewerWindow->setup3DRender(); // update all the sky/atmospheric/water settings - LLWLParamManager::instance()->update(LLViewerCamera::getInstance()); - LLWaterParamManager::instance()->update(LLViewerCamera::getInstance()); + LLWLParamManager::getInstance()->update(LLViewerCamera::getInstance()); + LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance()); // Update land visibility too LLWorld::getInstance()->setLandFarClip(final_far); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index d4af5048c3..614eb6ed88 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7628,55 +7628,56 @@ class LLWorldEnvSettings : public view_listener_t LLFloaterReg::toggleInstance("env_settings"); return true; } - + else if(gSavedSettings.getBOOL("UseEnvironmentFromRegion")) + { + LLNotifications::instance().add("EnvLockedUsingRegion", LLSD()); + } + else + { if (tod == "sunrise") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.25); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.25); + LLWLParamManager::getInstance()->mAnimator.deactivate(); // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else if (tod == "noon") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.567); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.567); + LLWLParamManager::getInstance()->mAnimator.deactivate(); // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else if (tod == "sunset") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.75); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.75); + LLWLParamManager::getInstance()->mAnimator.deactivate(); // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else if (tod == "midnight") { // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime(0.0); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime(0.0); + LLWLParamManager::getInstance()->mAnimator.deactivate(); // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } else { - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LINDEN); + } } return true; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 98f16757b2..0ed254bbc5 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1365,6 +1365,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) capabilityNames.append("DispatchRegionInfo"); capabilityNames.append("EstateChangeInfo"); capabilityNames.append("EventQueueGet"); + capabilityNames.append("EnvironmentSettings"); capabilityNames.append("FetchInventory"); capabilityNames.append("ObjectMedia"); capabilityNames.append("ObjectMediaNavigate"); @@ -1494,3 +1495,8 @@ std::string LLViewerRegion::getDescription() const { return stringize(*this); } + +std::string LLViewerRegion::getDescription() const +{ + return stringize(*this); +} diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 038c831e59..307e2cf3a2 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -405,6 +405,11 @@ private: /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) LLCapabilityListener mCapabilityListener; + /// Post an event to this LLCapabilityListener to invoke a capability message on + /// this LLViewerRegion's server + /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) + LLCapabilityListener mCapabilityListener; + private: bool mAlive; // can become false if circuit disconnects diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d078c15316..fa30c1ae9e 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1492,6 +1492,16 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { - LLWLParamManager::instance()->updateShaderUniforms(shader); - LLWaterParamManager::instance()->updateShaderUniforms(shader); + LLWLParamManager::getInstance()->updateShaderUniforms(shader); + LLWaterParamManager::getInstance()->updateShaderUniforms(shader); +} + +LLViewerShaderMgr::shader_iter LLViewerShaderMgr::beginShaders() const +{ + return mShaderList.begin(); +} + +LLViewerShaderMgr::shader_iter LLViewerShaderMgr::endShaders() const +{ + return mShaderList.end(); } diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index db880fded6..e958cf1172 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -240,20 +240,12 @@ public: base_iter_t mIter; }; - shader_iter beginShaders() const - { - return mShaderList.begin(); - } - - shader_iter endShaders() const - { - return mShaderList.end(); - } - + shader_iter beginShaders() const; + shader_iter endShaders() const; - /* virtual */ std::string getShaderDirPrefix(void); // Virtual + /* virtual */ std::string getShaderDirPrefix(void); - /* virtual */ void updateShaderUniforms(LLGLSLShader * shader); // Virtual + /* virtual */ void updateShaderUniforms(LLGLSLShader * shader); private: diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 7ae8c2c07d..a6465f1c4f 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -356,7 +356,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mAtmHeight = ATM_HEIGHT; mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); - mSunDefaultPosition = LLVector3(LLWLParamManager::instance()->mCurParams.getVector("lightnorm", error)); + mSunDefaultPosition = LLVector3(LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error)); if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) { initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); @@ -638,24 +638,24 @@ void LLVOSky::initAtmospherics(void) bool error; // uniform parameters for convenience - dome_radius = LLWLParamManager::instance()->getDomeRadius(); - dome_offset_ratio = LLWLParamManager::instance()->getDomeOffset(); - sunlight_color = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("sunlight_color", error)); - ambient = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("ambient", error)); - //lightnorm = LLWLParamManager::instance()->mCurParams.getVector("lightnorm", error); - gamma = LLWLParamManager::instance()->mCurParams.getVector("gamma", error)[0]; - blue_density = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("blue_density", error)); - blue_horizon = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("blue_horizon", error)); - haze_density = LLWLParamManager::instance()->mCurParams.getVector("haze_density", error)[0]; - haze_horizon = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("haze_horizon", error)); - density_multiplier = LLWLParamManager::instance()->mCurParams.getVector("density_multiplier", error)[0]; - max_y = LLWLParamManager::instance()->mCurParams.getVector("max_y", error)[0]; - glow = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("glow", error)); - cloud_shadow = LLWLParamManager::instance()->mCurParams.getVector("cloud_shadow", error)[0]; - cloud_color = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("cloud_color", error)); - cloud_scale = LLWLParamManager::instance()->mCurParams.getVector("cloud_scale", error)[0]; - cloud_pos_density1 = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("cloud_pos_density1", error)); - cloud_pos_density2 = LLColor3(LLWLParamManager::instance()->mCurParams.getVector("cloud_pos_density2", error)); + dome_radius = LLWLParamManager::getInstance()->getDomeRadius(); + dome_offset_ratio = LLWLParamManager::getInstance()->getDomeOffset(); + sunlight_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("sunlight_color", error)); + ambient = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("ambient", error)); + //lightnorm = LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error); + gamma = LLWLParamManager::getInstance()->mCurParams.getVector("gamma", error)[0]; + blue_density = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_density", error)); + blue_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_horizon", error)); + haze_density = LLWLParamManager::getInstance()->mCurParams.getVector("haze_density", error)[0]; + haze_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("haze_horizon", error)); + density_multiplier = LLWLParamManager::getInstance()->mCurParams.getVector("density_multiplier", error)[0]; + max_y = LLWLParamManager::getInstance()->mCurParams.getVector("max_y", error)[0]; + glow = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("glow", error)); + cloud_shadow = LLWLParamManager::getInstance()->mCurParams.getVector("cloud_shadow", error)[0]; + cloud_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_color", error)); + cloud_scale = LLWLParamManager::getInstance()->mCurParams.getVector("cloud_scale", error)[0]; + cloud_pos_density1 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density1", error)); + cloud_pos_density2 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density2", error)); // light norm is different. We need the sun's direction, not the light direction // which could be from the moon. And we need to clamp it @@ -1025,7 +1025,7 @@ void LLVOSky::calcAtmospherics(void) // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio // between sunlight and point lights in windlight to normalize point lights. F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - LLWLParamManager::instance()->mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + LLWLParamManager::getInstance()->mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); mSunDiffuse = vary_SunlightColor; mSunAmbient = vary_AmbientColor; @@ -2115,7 +2115,7 @@ void LLVOSky::updateFog(const F32 distance) F32 depth = water_height - camera_height; // get the water param manager variables - float water_fog_density = LLWaterParamManager::instance()->getFogDensity(); + float water_fog_density = LLWaterParamManager::getInstance()->getFogDensity(); LLColor4 water_fog_color = LLDrawPoolWater::sWaterFogColor.mV; // adjust the color based on depth. We're doing linear approximations diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index ca57c0144b..5cb61b8734 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -568,7 +568,7 @@ void LLVOWLSky::buildFanBuffer(LLStrider & vertices, LLStrider & texCoords, LLStrider & indices) { - const F32 RADIUS = LLWLParamManager::instance()->getDomeRadius(); + const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); U32 i, num_slices; F32 phi0, theta, x0, y0, z0; @@ -629,7 +629,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, LLStrider & texCoords, LLStrider & indices) { - const F32 RADIUS = LLWLParamManager::instance()->getDomeRadius(); + const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); U32 i, j, num_slices, num_stacks; F32 phi0, theta, x0, y0, z0; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 7314894c2e..c984938303 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -57,8 +57,6 @@ #include "curl/curl.h" -LLWaterParamManager * LLWaterParamManager::sInstance = NULL; - LLWaterParamManager::LLWaterParamManager() : mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), mFogDensity(4, "waterFogDensity", 2), @@ -246,7 +244,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::instance()->getRotatedLightDir().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV); shader->uniform4fv("waterPlane", 1, mWaterPlane.mV); @@ -320,19 +318,6 @@ void LLWaterParamManager::update(LLViewerCamera * cam) } } -// static -void LLWaterParamManager::initClass(void) -{ - instance(); -} - -// static -void LLWaterParamManager::cleanupClass(void) -{ - delete sInstance; - sInstance = NULL; -} - bool LLWaterParamManager::addParamSet(const std::string& name, LLWaterParamSet& param) { // add a new one if not one there already @@ -439,17 +424,9 @@ F32 LLWaterParamManager::getFogDensity(void) return fogDensity; } -// static -LLWaterParamManager * LLWaterParamManager::instance() +// virtual static +void LLWaterParamManager::initSingleton() { - if(NULL == sInstance) - { - sInstance = new LLWaterParamManager(); - - sInstance->loadAllPresets(LLStringUtil::null); - - sInstance->getParamSet("Default", sInstance->mCurParams); - } - - return sInstance; + loadAllPresets(LLStringUtil::null); + getParamSet("Default", mCurParams); } diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index c479f1861c..d5919bbf68 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -212,13 +212,10 @@ struct WaterExpFloatControl /// WindLight parameter manager class - what controls all the wind light shaders -class LLWaterParamManager +class LLWaterParamManager : public LLSingleton { public: - LLWaterParamManager(); - ~LLWaterParamManager(); - /// load a preset file void loadAllPresets(const std::string & fileName); @@ -238,9 +235,6 @@ public: /// Update shader uniforms that have changed. void updateShaderUniforms(LLGLSLShader * shader); - /// Perform global initialization for this class. - static void initClass(void); - // Cleanup of global data that's only inited once per class. static void cleanupClass(); @@ -281,9 +275,6 @@ public: F32 getFogDensity(void); LLColor4 getFogColor(void); - // singleton pattern implementation - static LLWaterParamManager * instance(); - public: LLWaterParamSet mCurParams; @@ -311,11 +302,13 @@ public: F32 mDensitySliderValue; private: + friend class LLSingleton; + /*virtual*/ void initSingleton(); + LLWaterParamManager(); + ~LLWaterParamManager(); + LLVector4 mWaterPlane; F32 mWaterFogKS; - - // our parameter manager singleton instance - static LLWaterParamManager * sInstance; }; inline void LLWaterParamManager::setDensitySliderValue(F32 val) diff --git a/indra/newview/llwaterparamset.cpp b/indra/newview/llwaterparamset.cpp index 9457d631be..488b189e94 100644 --- a/indra/newview/llwaterparamset.cpp +++ b/indra/newview/llwaterparamset.cpp @@ -224,3 +224,46 @@ F32 LLWaterParamSet::getFloat(const std::string& paramName, bool& error) return 0; } +// Added for interpolation effect in DEV-33645 +// Based on LLWLParamSet::mix, but written by Jacob without an intimate knowledge of how WindLight works. +// The function definition existed in the header but was never implemented. If you think there is something +// wrong with this, you're probably right. Ask Jacob, Q, or a member of the original WindLight team. +void LLWaterParamSet::mix(LLWaterParamSet& src, LLWaterParamSet& dest, F32 weight) +{ + // Setup + LLSD srcVal, destVal; // LLSD holders for get/set calls, reusable + + // Iterate through values + for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) + { + // If param exists in both src and dest, set the holder variables, otherwise skip + if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) + { + srcVal = src.mParamValues[iter->first]; + destVal = dest.mParamValues[iter->first]; + } + else + { + continue; + } + + if(iter->second.isReal()) // If it's a real, interpolate directly + { + iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); + } + else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those + && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) + { + // Actually do interpolation: old value + (difference in values * factor) + for(int i=0; i < iter->second.size(); ++i) + { + // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation + iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); + } + } + else // Else, skip + { + continue; + } + } +} diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp index a94a2e41aa..2e249b9701 100644 --- a/indra/newview/llwlanimator.cpp +++ b/indra/newview/llwlanimator.cpp @@ -30,20 +30,31 @@ #include "llsky.h" #include "pipeline.h" #include "llwlparammanager.h" +#include "llwaterparammanager.h" -LLWLAnimator::LLWLAnimator() : mStartTime(0), mDayRate(1), mDayTime(0), - mIsRunning(FALSE), mUseLindenTime(false) +extern LLControlGroup gSavedSettings; + +F64 LLWLAnimator::INTERP_TOTAL_SECONDS = 3.f; + +LLWLAnimator::LLWLAnimator() : mStartTime(0.f), mDayRate(1.f), mDayTime(0.f), + mIsRunning(FALSE), mIsInterpolating(FALSE), mTimeType(TIME_LINDEN), + mInterpStartTime(), mInterpEndTime() { - mDayTime = 0; + mInterpBeginWL = new LLWLParamSet(); + mInterpBeginWater = new LLWaterParamSet(); + mInterpEndWater = new LLWaterParamSet(); } void LLWLAnimator::update(LLWLParamSet& curParams) { + llassert(mUseLindenTime != mUseLocalTime); + F64 curTime; curTime = getDayTime(); // don't do anything if empty - if(mTimeTrack.size() == 0) { + if(mTimeTrack.size() == 0) + { return; } @@ -53,13 +64,15 @@ void LLWLAnimator::update(LLWLParamSet& curParams) mSecondIt++; // grab the two tween iterators - while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) { + while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) + { mFirstIt++; mSecondIt++; } // scroll it around when you get to the end - if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) { + if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) + { mSecondIt = mTimeTrack.begin(); mFirstIt = mTimeTrack.end(); mFirstIt--; @@ -67,70 +80,109 @@ void LLWLAnimator::update(LLWLParamSet& curParams) F32 weight = 0; - if(mFirstIt->first < mSecondIt->first) { + if(mFirstIt->first < mSecondIt->first) + { // get the delta time and the proper weight weight = F32 (curTime - mFirstIt->first) / (mSecondIt->first - mFirstIt->first); // handle the ends - } else if(mFirstIt->first > mSecondIt->first) { + } + else if(mFirstIt->first > mSecondIt->first) + { // right edge of time line - if(curTime >= mFirstIt->first) { + if(curTime >= mFirstIt->first) + { weight = F32 (curTime - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); - // left edge of time line - } else { + } + else + { weight = F32 ((1 + curTime) - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); } - // handle same as whatever the last one is - } else { + } + else + { weight = 1; } + if(mIsInterpolating) + { + // *TODO_JACOB: this is kind of laggy. Not sure why. The part that lags is the curParams.mix call, and none of the other mixes. It works, though. + clock_t current = clock(); + if(current >= mInterpEndTime) + { + mIsInterpolating = false; + return; + } + + // determine moving target for final interpolation value + LLWLParamSet buf = LLWLParamSet(); + buf.setAll(LLWLParamManager::getInstance()->mParamList[mFirstIt->second].getAll()); // just give it some values, otherwise it has no params to begin with (see comment in constructor) + buf.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); // mix to determine moving target for interpolation finish (as below) + + // mix from previous value to moving target + weight = (current - mInterpStartTime) / (INTERP_TOTAL_SECONDS * CLOCKS_PER_SEC); + curParams.mix(*mInterpBeginWL, buf, weight); + + // mix water + LLWaterParamManager::getInstance()->mCurParams.mix(*mInterpBeginWater, *mInterpEndWater, weight); + } + else + { // do the interpolation and set the parameters - curParams.mix(LLWLParamManager::instance()->mParamList[mFirstIt->second], - LLWLParamManager::instance()->mParamList[mSecondIt->second], weight); + curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); + } } F64 LLWLAnimator::getDayTime() { - if(!mIsRunning) { + if(!mIsRunning) + { return mDayTime; } - - if(mUseLindenTime) { - + else if(mTimeType == TIME_LINDEN) + { F32 phase = gSky.getSunPhase() / F_PI; // we're not solving the non-linear equation that determines sun phase // we're just linearly interpolating between the major points if (phase <= 5.0 / 4.0) { mDayTime = (1.0 / 3.0) * phase + (1.0 / 3.0); - } else { + } + else + { mDayTime = phase - (1.0 / 2.0); } - if(mDayTime > 1) { + if(mDayTime > 1) + { mDayTime--; } return mDayTime; } + else if(mTimeType == TIME_LOCAL) + { + return getLocalTime(); + } // get the time; mDayTime = (LLTimer::getElapsedSeconds() - mStartTime) / mDayRate; // clamp it - if(mDayTime < 0) { + if(mDayTime < 0) + { mDayTime = 0; } - while(mDayTime > 1) { + while(mDayTime > 1) + { mDayTime--; } @@ -144,15 +196,18 @@ void LLWLAnimator::setDayTime(F64 dayTime) mDayTime = dayTime; // clamp it - if(mDayTime < 0) { + if(mDayTime < 0) + { mDayTime = 0; - } else if(mDayTime > 1) { + } + else if(mDayTime > 1) + { mDayTime = 1; } } -void LLWLAnimator::setTrack(std::map& curTrack, +void LLWLAnimator::setTrack(std::map& curTrack, F32 dayRate, F64 dayTime, bool run) { mTimeTrack = curTrack; @@ -161,3 +216,96 @@ void LLWLAnimator::setTrack(std::map& curTrack, mIsRunning = run; } + +void LLWLAnimator::startInterpolation(LLSD& targetWater) +{ + mInterpBeginWL->setAll(LLWLParamManager::getInstance()->mCurParams.getAll()); + mInterpBeginWater->setAll(LLWaterParamManager::getInstance()->mCurParams.getAll()); + + mInterpStartTime = clock(); + mInterpEndTime = mInterpStartTime + clock_t(INTERP_TOTAL_SECONDS) * CLOCKS_PER_SEC; + + // Don't set any ending WL -- this is continuously calculated as the animator updates since it's a moving target + mInterpEndWater->setAll(targetWater); + + mIsInterpolating = true; +} + +std::string LLWLAnimator::timeToString(F32 curTime) +{ + S32 hours; + S32 min; + bool isPM = false; + + // get hours and minutes + hours = (S32) (24.0 * curTime); + curTime -= ((F32) hours / 24.0f); + min = llround(24.0f * 60.0f * curTime); + + // handle case where it's 60 + if(min == 60) + { + hours++; + min = 0; + } + + // set for PM + if(hours >= 12 && hours < 24) + { + isPM = true; + } + + // convert to non-military notation + if(hours >= 24) + { + hours = 12; + } + else if(hours > 12) + { + hours -= 12; + } + else if(hours == 0) + { + hours = 12; + } + + // make the string + std::stringstream newTime; + newTime << hours << ":"; + + // double 0 + if(min < 10) + { + newTime << 0; + } + + // finish it + newTime << min << " "; + if(isPM) + { + newTime << "PM"; + } + else + { + newTime << "AM"; + } + + return newTime.str(); +} + +F64 LLWLAnimator::getLocalTime() +{ + char buffer[9]; + time_t rawtime; + struct tm* timeinfo; + + time(&rawtime); + timeinfo = localtime(&rawtime); + strftime(buffer, 9, "%H:%M:%S", timeinfo); + std::string timeStr(buffer); + + F64 tod = ((F64)atoi(timeStr.substr(0,2).c_str())) / 24.f + + ((F64)atoi(timeStr.substr(3,2).c_str())) / 1440.f + + ((F64)atoi(timeStr.substr(6,2).c_str())) / 86400.f; + return tod; +} diff --git a/indra/newview/llwlanimator.h b/indra/newview/llwlanimator.h index 5677290213..07c2fa2328 100644 --- a/indra/newview/llwlanimator.h +++ b/indra/newview/llwlanimator.h @@ -28,28 +28,39 @@ #define LL_WL_ANIMATOR_H #include "llwlparamset.h" +#include "llwaterparamset.h" #include #include +struct LLWLParamKey; + class LLWLAnimator { public: + typedef enum e_time + { + TIME_LINDEN, + TIME_LOCAL, + TIME_CUSTOM + } ETime; + F64 mStartTime; F32 mDayRate; F64 mDayTime; // track to play - std::map mTimeTrack; - std::map::iterator mFirstIt, mSecondIt; - - // params to use - //std::map mParamList; - - bool mIsRunning; - bool mUseLindenTime; + std::map mTimeTrack; + std::map::iterator mFirstIt, mSecondIt; // simple constructor LLWLAnimator(); + ~LLWLAnimator() + { + delete mInterpBeginWL; + delete mInterpBeginWater; + delete mInterpEndWater; + } + // update the parameters void update(LLWLParamSet& curParams); @@ -63,9 +74,66 @@ public: void setDayTime(F64 dayTime); // set an animation track - void setTrack(std::map& track, + void setTrack(std::map& track, F32 dayRate, F64 dayTime = 0, bool run = true); + void deactivate() + { + mIsRunning = false; + } + + void activate(ETime time) + { + mIsRunning = true; + mTimeType = time; + } + + void startInterpolation(LLSD& targetWater); + + bool getIsRunning() + { + return mIsRunning; + } + + bool getUseCustomTime() + { + return mTimeType == TIME_CUSTOM; + } + + bool getUseLocalTime() + { + return mTimeType == TIME_LOCAL; + } + + bool getUseLindenTime() + { + return mTimeType == TIME_LINDEN; + } + + void setTimeType(ETime time) + { + mTimeType = time; + } + + ETime getTimeType() + { + return mTimeType; + } + + /// convert the present time to a digital clock time + static std::string timeToString(F32 curTime); + + /// get local time between 0 and 1 + static F64 getLocalTime(); + +private: + ETime mTimeType; + bool mIsRunning, mIsInterpolating; + LLWLParamSet *mInterpBeginWL; + LLWaterParamSet *mInterpBeginWater, *mInterpEndWater; + clock_t mInterpStartTime, mInterpEndTime; + + static F64 INTERP_TOTAL_SECONDS; }; #endif // LL_WL_ANIMATOR_H diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 85b3d62a49..52bbb4b5fc 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -2,37 +2,42 @@ * @file llwldaycycle.cpp * @brief Implementation for the LLWLDayCycle class. * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ #include "llviewerprecompiledheaders.h" #include "llwldaycycle.h" - -#include "llnotificationsutil.h" #include "llsdserialize.h" -#include "llxmlnode.h" - #include "llwlparammanager.h" +#include "llfloaterdaycycle.h" + +#include "llviewerwindow.h" #include @@ -45,85 +50,111 @@ LLWLDayCycle::~LLWLDayCycle() { } -void LLWLDayCycle::loadDayCycle(const std::string & fileName) +void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope) { - // clear the first few things mTimeMap.clear(); - // now load the file - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, - "windlight/days", fileName)); - llinfos << "Loading DayCycle settings from " << pathName << llendl; - - llifstream day_cycle_xml(pathName); - if (day_cycle_xml.is_open()) + // add each key frame + for(S32 i = 0; i < day_data.size(); ++i) { - // load and parse it - LLSD day_data(LLSD::emptyArray()); - LLPointer parser = new LLSDXMLParser(); - parser->parse(day_cycle_xml, day_data, LLSDSerialize::SIZE_UNLIMITED); - - // add each key - for(S32 i = 0; i < day_data.size(); ++i) + // make sure it's a two array + if(day_data[i].size() != 2) + { + continue; + } + + // check each param key exists in param manager + bool success; + LLWLParamSet pset; + LLWLParamKey frame = LLWLParamKey(day_data[i][1].asString(), scope); + success = + LLWLParamManager::getInstance()->getParamSet(frame, pset); + if(!success) { - // make sure it's a two array - if(day_data[i].size() != 2) + // *HACK try the local-scope ones for "A-something" defaults + // (because our envManager.lindenDefault() doesn't have the skies yet) + if (frame.name.find("A-") == 0) { - continue; + frame.scope = LLEnvKey::SCOPE_LOCAL; + success = LLWLParamManager::getInstance()->getParamSet(frame, pset); } - - // check each param name exists in param manager - bool success; - LLWLParamSet pset; - success = LLWLParamManager::instance()->getParamSet(day_data[i][1].asString(), pset); - if(!success) + + if (!success) { // alert the user LLSD args; args["SKY"] = day_data[i][1].asString(); - LLNotificationsUtil::add("WLMissingSky", args); + LLNotifications::instance().add("WLMissingSky", args); continue; } - - // then add the key - addKey((F32)day_data[i][0].asReal(), day_data[i][1].asString()); } + + // then add the keyframe + addKeyframe((F32)day_data[i][0].asReal(), frame); + } +} + +void LLWLDayCycle::loadDayCycleFromFile(const std::string & fileName) +{ + loadDayCycle(loadCycleDataFromFile(fileName), LLWLParamKey::SCOPE_LOCAL); +} +/*static*/ LLSD LLWLDayCycle::loadCycleDataFromFile(const std::string & fileName) +{ + // now load the file + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, + "windlight/days", fileName)); + llinfos << "Loading DayCycle settings from " << pathName << llendl; + + llifstream day_cycle_xml(pathName); + if (day_cycle_xml.is_open()) + { + // load and parse it + LLSD day_data(LLSD::emptyArray()); + LLPointer parser = new LLSDXMLParser(); + parser->parse(day_cycle_xml, day_data, LLSDSerialize::SIZE_UNLIMITED); day_cycle_xml.close(); + return day_data; + } + else + { + return LLSD(); } } void LLWLDayCycle::saveDayCycle(const std::string & fileName) { - LLSD day_data(LLSD::emptyArray()); + LLSD day_data = asLLSD(); std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); //llinfos << "Saving WindLight settings to " << pathName << llendl; - for(std::map::const_iterator mIt = mTimeMap.begin(); - mIt != mTimeMap.end(); - ++mIt) - { - LLSD key(LLSD::emptyArray()); - key.append(mIt->first); - key.append(mIt->second); - day_data.append(key); - } - llofstream day_cycle_xml(pathName); LLPointer formatter = new LLSDXMLFormatter(); formatter->format(day_data, day_cycle_xml, LLSDFormatter::OPTIONS_PRETTY); day_cycle_xml.close(); } +LLSD LLWLDayCycle::asLLSD() +{ + LLSD day_data(LLSD::emptyArray()); + for(std::map::const_iterator mIt = mTimeMap.begin(); mIt != mTimeMap.end(); ++mIt) + { + LLSD key(LLSD::emptyArray()); + key.append(mIt->first); + key.append(mIt->second.name); + day_data.append(key); + } + return day_data; +} -void LLWLDayCycle::clearKeys() +void LLWLDayCycle::clearKeyframes() { mTimeMap.clear(); } -bool LLWLDayCycle::addKey(F32 newTime, const std::string & paramName) +bool LLWLDayCycle::addKeyframe(F32 newTime, LLWLParamKey frame) { // no adding negative time if(newTime < 0) @@ -134,7 +165,7 @@ bool LLWLDayCycle::addKey(F32 newTime, const std::string & paramName) // if time not being used, add it and return true if(mTimeMap.find(newTime) == mTimeMap.end()) { - mTimeMap.insert(std::pair(newTime, paramName)); + mTimeMap.insert(std::pair(newTime, frame)); return true; } @@ -142,40 +173,40 @@ bool LLWLDayCycle::addKey(F32 newTime, const std::string & paramName) return false; } -bool LLWLDayCycle::changeKeyTime(F32 oldTime, F32 newTime) +bool LLWLDayCycle::changeKeyframeTime(F32 oldTime, F32 newTime) { // just remove and add back - std::string name = mTimeMap[oldTime]; + LLWLParamKey frame = mTimeMap[oldTime]; - bool stat = removeKey(oldTime); + bool stat = removeKeyframe(oldTime); if(stat == false) { return stat; } - return addKey(newTime, name); + return addKeyframe(newTime, frame); } -bool LLWLDayCycle::changeKeyParam(F32 time, const std::string & name) +bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key) { // just remove and add back // make sure param exists LLWLParamSet tmp; - bool stat = LLWLParamManager::instance()->getParamSet(name, tmp); + bool stat = LLWLParamManager::getInstance()->getParamSet(key, tmp); if(stat == false) { return stat; } - mTimeMap[time] = name; + mTimeMap[time] = key; return true; } -bool LLWLDayCycle::removeKey(F32 time) +bool LLWLDayCycle::removeKeyframe(F32 time) { // look for the time. If there, erase it - std::map::iterator mIt = mTimeMap.find(time); + std::map::iterator mIt = mTimeMap.find(time); if(mIt != mTimeMap.end()) { mTimeMap.erase(mIt); @@ -185,15 +216,15 @@ bool LLWLDayCycle::removeKey(F32 time) return false; } -bool LLWLDayCycle::getKey(const std::string & name, F32& key) +bool LLWLDayCycle::getKeytime(LLWLParamKey frame, F32& key_time) { - // scroll through till we find the - std::map::iterator mIt = mTimeMap.begin(); + // scroll through till we find the correct value in the map + std::map::iterator mIt = mTimeMap.begin(); for(; mIt != mTimeMap.end(); ++mIt) { - if(name == mIt->second) + if(frame == mIt->second) { - key = mIt->first; + key_time = mIt->first; return true; } } @@ -204,10 +235,10 @@ bool LLWLDayCycle::getKey(const std::string & name, F32& key) bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) { // just scroll on through till you find it - std::map::iterator mIt = mTimeMap.find(time); - if(mIt != mTimeMap.end()) + std::map::iterator mIt = mTimeMap.find(time); + if(mIt != mTimeMap.end()) { - return LLWLParamManager::instance()->getParamSet(mIt->second, param); + return LLWLParamManager::getInstance()->getParamSet(mIt->second, param); } // return error if not found @@ -217,13 +248,30 @@ bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) bool LLWLDayCycle::getKeyedParamName(F32 time, std::string & name) { // just scroll on through till you find it - std::map::iterator mIt = mTimeMap.find(time); + std::map::iterator mIt = mTimeMap.find(time); if(mIt != mTimeMap.end()) { - name = mTimeMap[time]; + name = mTimeMap[time].name; return true; } // return error if not found return false; } + +void LLWLDayCycle::removeReferencesTo(const LLWLParamKey& keyframe) +{ + F32 keytime; + bool might_exist; + do + { + // look for it + might_exist = getKeytime(keyframe, keytime); + if(!might_exist) + { + return; + } + might_exist = removeKeyframe(keytime); + + } while(might_exist); // might be another one +} diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index 5cbf72191d..d56194a74a 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -34,13 +34,15 @@ class LLWLDayCycle; #include #include "llwlparamset.h" #include "llwlanimator.h" +struct LLWLParamKey; +#include "llenvmanager.h" // for LLEnvKey::EScope class LLWLDayCycle { public: // lists what param sets are used when during the day - std::map mTimeMap; + std::map mTimeMap; // how long is my day F32 mDayRate; @@ -54,35 +56,44 @@ public: ~LLWLDayCycle(); /// load a day cycle - void loadDayCycle(const std::string & fileName); + void loadDayCycle(const LLSD& llsd, LLEnvKey::EScope scope); + + /// load a day cycle + void loadDayCycleFromFile(const std::string & fileName); /// load a day cycle void saveDayCycle(const std::string & fileName); - /// clear keys - void clearKeys(); + /// load the LLSD data from a file (returns the undefined LLSD if not found) + static LLSD loadCycleDataFromFile(const std::string & fileName); + + /// get the LLSD data for this day cycle + LLSD asLLSD(); + + /// clear keyframes + void clearKeyframes(); /// Getters and Setters /// add a new key frame to the day cycle /// returns true if successful /// no negative time - bool addKey(F32 newTime, const std::string & paramName); + bool addKeyframe(F32 newTime, LLWLParamKey key); - /// adjust a key's placement in the day cycle + /// adjust a keyframe's placement in the day cycle /// returns true if successful - bool changeKeyTime(F32 oldTime, F32 newTime); + bool changeKeyframeTime(F32 oldTime, F32 newTime); - /// adjust a key's parameter used + /// adjust a keyframe's parameter used /// returns true if successful - bool changeKeyParam(F32 time, const std::string & paramName); + bool changeKeyframeParam(F32 time, LLWLParamKey key); - /// remove a key from the day cycle + /// remove a key frame from the day cycle /// returns true if successful - bool removeKey(F32 time); + bool removeKeyframe(F32 time); /// get the first key time for a parameter /// returns false if not there - bool getKey(const std::string & name, F32& key); + bool getKeytime(LLWLParamKey keyFrame, F32& keyTime); /// get the param set at a given time /// returns true if found one @@ -92,6 +103,9 @@ public: /// returns true if it found one bool getKeyedParamName(F32 time, std::string & name); + /// removes all references to the sky (paramkey) + /// does nothing if the sky doesn't exist in the day + void removeReferencesTo(const LLWLParamKey& keyframe); }; diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp new file mode 100644 index 0000000000..c4f11cf00a --- /dev/null +++ b/indra/newview/llwlhandlers.cpp @@ -0,0 +1,159 @@ +/** + * @file llwlhandlers.cpp + * @brief Various classes which handle Windlight-related messaging + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llwlhandlers.h" + +#include "llagent.h" +#include "llviewerregion.h" +#include "llenvmanager.h" + +/**** + * LLEnvironmentRequestResponder + ****/ +int LLEnvironmentRequestResponder::sCount = 0; // init to 0 + +/*static*/ bool LLEnvironmentRequestResponder::initiateRequest() +{ + std::string url = gAgent.getRegion()->getCapability("EnvironmentSettings"); + if (url.empty()) + { + LL_INFOS("WindlightCaps") << "Skipping windlight setting request - we don't have this capability" << LL_ENDL; + // region is apparently not capable of this; don't respond at all + return false; + } + else + { + LL_DEBUGS("WindlightCaps") << "Requesting windlight settings via " << url << LL_ENDL; + LLHTTPClient::get(url, new LLEnvironmentRequestResponder()); + return true; + } +} +LLEnvironmentRequestResponder::LLEnvironmentRequestResponder() +{ + mID = ++sCount; +} +/*virtual*/ void LLEnvironmentRequestResponder::result(const LLSD& unvalidated_content) +{ + LL_DEBUGS("WindlightCaps") << "Receiving windlight settings..." << LL_ENDL; + + if (mID != sCount) + { + LL_INFOS("WindlightCaps") << "Got superseded by another responder; ignoring..." << LL_ENDL; + return; + } + + if (unvalidated_content[0]["regionID"].asUUID() != gAgent.getRegion()->getRegionID()) + { + LL_WARNS("WindlightCaps") << "Not in the region from where this data was received (wanting " + << gAgent.getRegion()->getRegionID() << " but got " << unvalidated_content[0]["regionID"].asUUID() + << ") - ignoring..." << LL_ENDL; + return; + } + + LLEnvManager::getInstance()->processIncomingMessage(unvalidated_content, LLEnvKey::SCOPE_REGION); +} +/*virtual*/ void LLEnvironmentRequestResponder::error(U32 status, const std::string& reason) +{ + LL_INFOS("WindlightCaps") << "Got an error, not using region windlight..." << LL_ENDL; + // notify manager that region settings are undefined + LLEnvManager::getInstance()->processIncomingMessage(LLSD(), LLEnvKey::SCOPE_REGION); +} + + +/**** + * LLEnvironmentApplyResponder + ****/ +clock_t LLEnvironmentApplyResponder::UPDATE_WAIT_SECONDS = clock_t(3.f); +clock_t LLEnvironmentApplyResponder::sLastUpdate = clock_t(0.f); + +bool LLEnvironmentApplyResponder::initiateRequest(const LLSD& content) +{ + clock_t current = clock(); + if(current >= sLastUpdate + (UPDATE_WAIT_SECONDS * CLOCKS_PER_SEC)) + { + sLastUpdate = current; + } + else + { + LLSD args(LLSD::emptyMap()); + args["WAIT"] = (F64)UPDATE_WAIT_SECONDS; + LLNotifications::instance().add("EnvUpdateRate", args); + return false; + } + + std::string url = gAgent.getRegion()->getCapability("EnvironmentSettings"); + if (!url.empty()) + { + LL_INFOS("WindlightCaps") << "Sending windlight settings to " << url << LL_ENDL; + LLHTTPClient::post(url, content, new LLEnvironmentApplyResponder()); + return true; + } + return false; +} +/*virtual*/ void LLEnvironmentApplyResponder::result(const LLSD& content) +{ + if (content["regionID"].asUUID() != gAgent.getRegion()->getRegionID()) + { + LL_WARNS("WindlightCaps") << "No longer in the region where data was sent (currently " + << gAgent.getRegion()->getRegionID() << ", reply is from " << content["regionID"].asUUID() + << "); ignoring..." << LL_ENDL; + return; + } + else if (content["success"].asBoolean()) + { + LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << content["regionID"].asUUID() << LL_ENDL; + } + else + { + LL_WARNS("WindlightCaps") << "Region couldn't apply windlight settings! Reason from sim: " << content["fail_reason"].asString() << LL_ENDL; + LLSD args(LLSD::emptyMap()); + args["FAIL_REASON"] = content["fail_reason"].asString(); + LLNotifications::instance().add("WLRegionApplyFail", args); + } + + LLEnvManager::getInstance()->commitSettingsFinished(LLEnvKey::SCOPE_REGION); +} +/*virtual*/ void LLEnvironmentApplyResponder::error(U32 status, const std::string& reason) +{ + std::stringstream msg; + msg << reason << " (Code " << status << ")"; + + LL_WARNS("WindlightCaps") << "Couldn't apply windlight settings to region! Reason: " << msg << LL_ENDL; + + LLSD args(LLSD::emptyMap()); + args["FAIL_REASON"] = msg.str(); + LLNotifications::instance().add("WLRegionApplyFail", args); + + LLEnvManager::getInstance()->commitSettingsFinished(LLEnvKey::SCOPE_REGION); +} diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h new file mode 100644 index 0000000000..a50404f2e1 --- /dev/null +++ b/indra/newview/llwlhandlers.h @@ -0,0 +1,89 @@ +/** + * @file llwlhandlers.h + * @brief Headers for classes in llwlhandlers.cpp + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLWLHANDLERS_H +#define LL_LLWLHANDLERS_H + +#include "llviewerprecompiledheaders.h" + +class LLEnvManager; + +class LLEnvironmentRequestResponder: public LLHTTPClient::Responder +{ +public: + virtual void result(const LLSD& content); + virtual void error(U32 status, const std::string& reason); + +private: + friend class LLEnvManager; + // returns true if request was sucessfully sent + static bool initiateRequest(); + + LLEnvironmentRequestResponder(); + static int sCount; + int mID; +}; + +class LLEnvironmentApplyResponder: public LLHTTPClient::Responder +{ +public: + /* + * Expecting reply from sim in form of: + * { + * regionID : uuid, + * messageID: uuid, + * success : true + * } + * or + * { + * regionID : uuid, + * success : false, + * fail_reason : string + * } + */ + virtual void result(const LLSD& content); + + virtual void error(U32 status, const std::string& reason); // non-200 errors only + +private: + friend class LLEnvManager; + + static clock_t sLastUpdate; + static clock_t UPDATE_WAIT_SECONDS; + + // for format of packet expected, see llwlscrubbers.cpp in llmessage + static bool initiateRequest(const LLSD& packet); + + LLEnvironmentApplyResponder() {} +}; + +#endif // LL_LLWLHANDLERS_H diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 9b6047395a..493d066942 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -2,25 +2,31 @@ * @file llwlparammanager.cpp * @brief Implementation for the LLWLParamManager class. * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -31,28 +37,34 @@ #include "pipeline.h" #include "llsky.h" -#include "llfloaterreg.h" #include "llsliderctrl.h" #include "llspinctrl.h" #include "llcheckboxctrl.h" #include "lluictrlfactory.h" +#include "llviewercamera.h" #include "llcombobox.h" #include "lllineeditor.h" #include "llsdserialize.h" #include "v4math.h" +#include "llviewerdisplay.h" #include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "lldrawpoolwater.h" +#include "llagent.h" +#include "llviewerregion.h" +#include "llenvmanager.h" #include "llwlparamset.h" #include "llpostprocess.h" #include "llfloaterwindlight.h" #include "llfloaterdaycycle.h" #include "llfloaterenvsettings.h" +#include "llviewershadermgr.h" +#include "llglslshader.h" #include "curl/curl.h" - -LLWLParamManager * LLWLParamManager::sInstance = NULL; -static LLFastTimer::DeclareTimer FTM_UPDATE_WLPARAM("Update Windlight Params"); +#include "llstreamtools.h" LLWLParamManager::LLWLParamManager() : @@ -95,19 +107,150 @@ LLWLParamManager::~LLWLParamManager() { } +void LLWLParamManager::clearParamSetsOfScope(LLWLParamKey::EScope scope) +{ + if (LLWLParamKey::SCOPE_LOCAL == scope) + { + LL_WARNS("Windlight") << "Tried to clear windlight sky presets from local system! This shouldn't be called..." << LL_ENDL; + return; + } + + std::set to_remove; + for(std::map::iterator iter = mParamList.begin(); iter != mParamList.end(); ++iter) + { + if(iter->first.scope == scope) + { + to_remove.insert(iter->first); + } + } + + for(std::set::iterator iter = to_remove.begin(); iter != to_remove.end(); ++iter) + { + mParamList.erase(*iter); + } +} + +// returns all skies referenced by the day cycle, with their final names +// side effect: applies changes to all internal structures! +std::map LLWLParamManager::finalizeFromDayCycle(LLWLParamKey::EScope scope) +{ + std::map final_references; + + // Move all referenced to desired scope, renaming if necessary + // First, save skies referenced + std::map current_references; // all skies referenced by the day cycle, with their current names + // guard against skies with same name and different scopes + std::set inserted_names; + std::map conflicted_names; // integer later used as a count, for uniquely renaming conflicts + + LLWLDayCycle& cycle = mDay; + for(std::map::iterator iter = cycle.mTimeMap.begin(); + iter != cycle.mTimeMap.end(); + ++iter) + { + LLWLParamKey& key = iter->second; + std::string desired_name = key.name; + replace_newlines_with_whitespace(desired_name); // already shouldn't have newlines, but just in case + if(inserted_names.find(desired_name) == inserted_names.end()) + { + inserted_names.insert(desired_name); + } + else + { + // make exist in map + conflicted_names[desired_name] = 0; + } + current_references[key] = mParamList[key]; + } + + // forget all old skies in target scope, and rebuild, renaming as needed + clearParamSetsOfScope(scope); + for(std::map::iterator iter = current_references.begin(); iter != current_references.end(); ++iter) + { + const LLWLParamKey& old_key = iter->first; + + std::string desired_name(old_key.name); + replace_newlines_with_whitespace(desired_name); + + LLWLParamKey new_key(desired_name, scope); // name will be replaced later if necessary + + // if this sky is one with a non-unique name, rename via appending a number + // an existing preset of the target scope gets to keep its name + if (scope != old_key.scope && conflicted_names.find(desired_name) != conflicted_names.end()) + { + std::string& new_name = new_key.name; + + do + { + // if this executes more than once, this is an absurdly pathological case + // (e.g. "x" repeated twice, but "x 1" already exists, so need to use "x 2") + std::stringstream temp; + temp << desired_name << " " << (++conflicted_names[desired_name]); + new_name = temp.str(); + } while (inserted_names.find(new_name) != inserted_names.end()); + + // yay, found one that works + inserted_names.insert(new_name); // track names we consume here; shouldn't be necessary due to ++int? but just in case + + // *TODO factor out below into a rename()? + + LL_INFOS("Windlight") << "Renamed " << old_key.name << " (scope" << old_key.scope << ") to " + << new_key.name << " (scope " << new_key.scope << ")" << LL_ENDL; + + // update name in sky + iter->second.mName = new_name; + + // update keys in day cycle + for(std::map::iterator frame = cycle.mTimeMap.begin(); frame != cycle.mTimeMap.end(); ++frame) + { + if (frame->second == old_key) + { + frame->second = new_key; + } + } + + // add to master sky map + mParamList[new_key] = iter->second; + } + + final_references[new_key] = iter->second; + } + + return final_references; +} + +LLSD LLWLParamManager::createSkyMap(std::map refs) +{ + LLSD skies = LLSD::emptyMap(); + for(std::map::iterator iter = refs.begin(); iter != refs.end(); ++iter) + { + skies.insert(iter->first.name, iter->second.getAll()); + } + return skies; +} + +void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& sky_presets) +{ + for(LLSD::map_const_iterator iter = sky_presets.beginMap(); iter != sky_presets.endMap(); ++iter) + { + LLWLParamSet set; + set.setAll(iter->second); + mParamList[LLWLParamKey(iter->first, scope)] = set; + } +} + void LLWLParamManager::loadPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); - LL_DEBUGS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL; - - bool found = true; + LL_INFOS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL; + + bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); if(found) { - name=name.erase(name.length()-4); // bugfix for SL-46920: preventing filenames that break stuff. @@ -117,16 +260,16 @@ void LLWLParamManager::loadPresets(const std::string& file_name) curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - loadPreset(unescaped_name,FALSE); + loadPreset(LLWLParamKey(unescaped_name, LLWLParamKey::SCOPE_LOCAL),FALSE); } } // And repeat for user presets, note the user presets will modify any system presets already loaded std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); - LL_DEBUGS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL; - - found = true; + LL_INFOS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL; + + found = true; while(found) { std::string name; @@ -142,12 +285,14 @@ void LLWLParamManager::loadPresets(const std::string& file_name) curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - loadPreset(unescaped_name,FALSE); + loadPreset(LLWLParamKey(unescaped_name,LLWLParamKey::SCOPE_LOCAL),FALSE); } } } +// untested and unmaintained! sanity-check me before using +/* void LLWLParamManager::savePresets(const std::string & fileName) { //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder @@ -157,11 +302,11 @@ void LLWLParamManager::savePresets(const std::string & fileName) std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", fileName)); - for(std::map::iterator mIt = mParamList.begin(); + for(std::map::iterator mIt = mParamList.begin(); mIt != mParamList.end(); ++mIt) { - paramsData[mIt->first] = mIt->second.getAll(); + paramsData[mIt->first.name] = mIt->second.getAll(); } llofstream presetsXML(pathName); @@ -172,70 +317,78 @@ void LLWLParamManager::savePresets(const std::string & fileName) presetsXML.close(); } +*/ -void LLWLParamManager::loadPreset(const std::string & name,bool propagate) +void LLWLParamManager::loadPreset(const LLWLParamKey key, bool propagate) { - - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_escape(name.c_str(), name.size()); - std::string escaped_filename(curl_str); - curl_free(curl_str); - curl_str = NULL; - - escaped_filename += ".xml"; - - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading WindLight sky setting from " << pathName << LL_ENDL; - - llifstream presetsXML; - presetsXML.open(pathName.c_str()); - - // That failed, try loading from the users area instead. - if(!presetsXML) + if(mParamList.find(key) == mParamList.end()) // key does not already exist in mapping { - pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename); - LL_DEBUGS2("AppInit", "Shaders") << "Loading User WindLight sky setting from " << pathName << LL_ENDL; - presetsXML.clear(); - presetsXML.open(pathName.c_str()); - } + if(key.scope == LLWLParamKey::SCOPE_LOCAL) // local scope, so try to load from file + { + // bugfix for SL-46920: preventing filenames that break stuff. + char * curl_str = curl_escape(key.name.c_str(), key.name.size()); + std::string escaped_filename(curl_str); + curl_free(curl_str); + curl_str = NULL; - if (presetsXML) - { - LLSD paramsData(LLSD::emptyMap()); + escaped_filename += ".xml"; - LLPointer parser = new LLSDXMLParser(); + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); + llinfos << "Loading WindLight sky setting from " << pathName << llendl; - parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); + llifstream presetsXML; + presetsXML.open(pathName.c_str()); - std::map::iterator mIt = mParamList.find(name); - if(mIt == mParamList.end()) - { - addParamSet(name, paramsData); + // That failed, try loading from the users area instead. + if(!presetsXML) + { + pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename); + llinfos << "Loading User WindLight sky setting from " << pathName << llendl; + presetsXML.open(pathName.c_str()); + } + + if (presetsXML) + { + loadPresetFromXML(key, presetsXML); + presetsXML.close(); + } + else + { + llwarns << "Could not load local WindLight sky setting " << key.toString() << llendl; + return; + } } - else + else { - setParamSet(name, paramsData); - } - presetsXML.close(); - } - else - { - llwarns << "Can't find " << name << llendl; - return; + llwarns << "Attempted to load non-local WindLight sky settings " << key.toString() << "; not found in parameter mapping." << llendl; + return; + } } - if(propagate) { - getParamSet(name, mCurParams); + getParamSet(key, mCurParams); propagateParameters(); } -} +} -void LLWLParamManager::savePreset(const std::string & name) +void LLWLParamManager::loadPresetFromXML(LLWLParamKey key, std::istream & presetsXML) +{ + LLSD paramsData(LLSD::emptyMap()); + LLPointer parser = new LLSDXMLParser(); + + parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); + + std::map::iterator mIt = mParamList.find(key); + + if(mIt == mParamList.end()) addParamSet(key, paramsData); + else setParamSet(key, paramsData); +} + +void LLWLParamManager::savePreset(LLWLParamKey key) { // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_escape(name.c_str(), name.size()); + char * curl_str = curl_escape(key.name.c_str(), key.name.size()); std::string escaped_filename(curl_str); curl_free(curl_str); curl_str = NULL; @@ -247,7 +400,7 @@ void LLWLParamManager::savePreset(const std::string & name) std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename)); // fill it with LLSD windlight params - paramsData = mParamList[name].getAll(); + paramsData = mParamList[key].getAll(); // write to file llofstream presetsXML(pathName); @@ -282,7 +435,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) void LLWLParamManager::propagateParameters(void) { - LLFastTimer ftm(FTM_UPDATE_WLPARAM); + LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); LLVector4 sunDir; LLVector4 moonDir; @@ -306,7 +459,7 @@ void LLWLParamManager::propagateParameters(void) { mLightDir = sunDir; } - else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) + else if(sunDir.mV[1] < 0 && sunDir.mV[1] > NIGHTTIME_ELEVATION_COS) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); @@ -353,13 +506,13 @@ void LLWLParamManager::propagateParameters(void) void LLWLParamManager::update(LLViewerCamera * cam) { - LLFastTimer ftm(FTM_UPDATE_WLPARAM); + LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); // update clouds, sun, and general mCurParams.updateCloudScrolling(); // update only if running - if(mAnimator.mIsRunning) + if(mAnimator.getIsRunning()) { mAnimator.update(mCurParams); } @@ -368,30 +521,29 @@ void LLWLParamManager::update(LLViewerCamera * cam) propagateParameters(); // sync menus if they exist - LLFloaterWindLight* wlfloater = LLFloaterReg::findTypedInstance("env_windlight"); - if (wlfloater) + if(LLFloaterWindLight::isOpen()) { - wlfloater->syncMenu(); + LLFloaterWindLight::instance()->syncMenu(); } - LLFloaterDayCycle* dlfloater = LLFloaterReg::findTypedInstance("env_day_cycle"); - if (dlfloater) + if(LLFloaterDayCycle::isOpen()) { - dlfloater->syncMenu(); + LLFloaterDayCycle::instance()->syncMenu(); } - LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("env_settings"); - if (envfloater) + if(LLFloaterEnvSettings::isOpen()) { - envfloater->syncMenu(); + LLFloaterEnvSettings::instance()->syncMenu(); } F32 camYaw = cam->getYaw(); + stop_glerror(); + // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; - LLVector3 lightNorm3(mLightDir); + LLVector3 lightNorm3(mLightDir); lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); mRotatedLightDir = LLVector4(lightNorm3, 0.f); @@ -409,19 +561,6 @@ void LLWLParamManager::update(LLViewerCamera * cam) } } -// static -void LLWLParamManager::initClass(void) -{ - instance(); -} - -// static -void LLWLParamManager::cleanupClass() -{ - delete sInstance; - sInstance = NULL; -} - void LLWLParamManager::resetAnimator(F32 curTime, bool run) { mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, @@ -429,26 +568,27 @@ void LLWLParamManager::resetAnimator(F32 curTime, bool run) return; } -bool LLWLParamManager::addParamSet(const std::string& name, LLWLParamSet& param) + +bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) { // add a new one if not one there already - std::map::iterator mIt = mParamList.find(name); + std::map::iterator mIt = mParamList.find(key); if(mIt == mParamList.end()) { - mParamList[name] = param; + mParamList[key] = param; return true; } return false; } -BOOL LLWLParamManager::addParamSet(const std::string& name, LLSD const & param) +BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) { // add a new one if not one there already - std::map::const_iterator finder = mParamList.find(name); + std::map::const_iterator finder = mParamList.find(key); if(finder == mParamList.end()) { - mParamList[name].setAll(param); + mParamList[key].setAll(param); return TRUE; } else @@ -457,105 +597,88 @@ BOOL LLWLParamManager::addParamSet(const std::string& name, LLSD const & param) } } -bool LLWLParamManager::getParamSet(const std::string& name, LLWLParamSet& param) +bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) { // find it and set it - std::map::iterator mIt = mParamList.find(name); + std::map::iterator mIt = mParamList.find(key); if(mIt != mParamList.end()) { - param = mParamList[name]; - param.mName = name; + param = mParamList[key]; + param.mName = key.name; return true; } return false; } -bool LLWLParamManager::setParamSet(const std::string& name, LLWLParamSet& param) +bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) { - mParamList[name] = param; + mParamList[key] = param; return true; } -bool LLWLParamManager::setParamSet(const std::string& name, const LLSD & param) +bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) { // quick, non robust (we won't be working with files, but assets) check + // this might not actually be true anymore.... if(!param.isMap()) { return false; } - mParamList[name].setAll(param); + mParamList[key].setAll(param); return true; } -bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_disk) +void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) { // remove from param list - std::map::iterator mIt = mParamList.find(name); + std::map::iterator mIt = mParamList.find(key); if(mIt != mParamList.end()) { mParamList.erase(mIt); } - - F32 key; - - // remove all references - bool stat = true; - do + else { - // get it - stat = mDay.getKey(name, key); - if(stat == false) - { - break; - } + LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << "; not found." << LL_ENDL; + } - // and remove - stat = mDay.removeKey(key); + mDay.removeReferencesTo(key); - } while(stat == true); - - if(delete_from_disk) + if(delete_from_disk && key.scope == LLWLParamKey::SCOPE_LOCAL) { std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); // use full curl escaped name - char * curl_str = curl_escape(name.c_str(), name.size()); + char * curl_str = curl_escape(key.name.c_str(), key.name.size()); std::string escaped_name(curl_str); curl_free(curl_str); curl_str = NULL; - gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); + if(gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml") < 1) + { + LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << " from disk; not found." << LL_ENDL; + } } - - return true; } -// static -LLWLParamManager * LLWLParamManager::instance() +// virtual static +void LLWLParamManager::initSingleton() { - if(NULL == sInstance) - { - sInstance = new LLWLParamManager(); + loadPresets(LLStringUtil::null); - sInstance->loadPresets(LLStringUtil::null); + // load the day + mDay.loadDayCycleFromFile(std::string("Default.xml")); - // load the day - sInstance->mDay.loadDayCycle(std::string("Default.xml")); + // *HACK - sets cloud scrolling to what we want... fix this better in the future + getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); - // *HACK - sets cloud scrolling to what we want... fix this better in the future - sInstance->getParamSet("Default", sInstance->mCurParams); - - // set it to noon - sInstance->resetAnimator(0.5, true); - - // but use linden time sets it to what the estate is - sInstance->mAnimator.mUseLindenTime = true; - } + // set it to noon + resetAnimator(0.5, true); - return sInstance; + // but use linden time sets it to what the estate is + mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); } diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 8c6329e769..1951366939 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -2,25 +2,31 @@ * @file llwlparammanager.h * @brief Implementation for the LLWLParamManager class. * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -29,10 +35,12 @@ #include #include +#include "llenvmanager.h" #include "llwlparamset.h" #include "llwlanimator.h" #include "llwldaycycle.h" #include "llviewercamera.h" +#include "lltrans.h" class LLGLSLShader; @@ -72,7 +80,7 @@ struct WLColorControl { r = val.mV[0]; g = val.mV[1]; b = val.mV[2]; - i = val.mV[3]; + i = val.mV[3]; return *this; } @@ -115,25 +123,110 @@ struct WLFloatControl { } }; -/// WindLight parameter manager class - what controls all the wind light shaders -class LLWLParamManager +struct LLWLParamKey : LLEnvKey { public: + // scope and source of a param set (WL sky preset) + std::string name; + EScope scope; - LLWLParamManager(); - ~LLWLParamManager(); + // for conversion from LLSD + static const int NAME_IDX = 0; + static const int SCOPE_IDX = 1; + + inline LLWLParamKey(const std::string& n, EScope s) + : name(n), scope(s) + { + } + inline LLWLParamKey(LLSD llsd) + : name(llsd[NAME_IDX].asString()), scope(EScope(llsd[SCOPE_IDX].asInteger())) + { + } + + inline LLWLParamKey() // NOT really valid, just so std::maps can return a default of some sort + : name(NULL), scope(SCOPE_LOCAL) + { + } + + inline LLWLParamKey(std::string& stringVal) + : name(stringVal.substr(0, stringVal.length()-1)), + scope((EScope)atoi(stringVal.substr(stringVal.length()-1, stringVal.length()).c_str())) + { + } + + inline std::string toStringVal() const + { + std::stringstream str; + str << name << scope; + return str.str(); + } + + inline LLSD toLLSD() const + { + LLSD llsd = LLSD::emptyArray(); + llsd.append(LLSD(name)); + llsd.append(LLSD(scope)); + return llsd; + } + + inline bool operator <(const LLWLParamKey other) const + { + if (name < other.name) + { + return true; + } + else if (name > other.name) + { + return false; + } + else + { + return scope < other.scope; + } + } + + inline bool operator ==(const LLWLParamKey other) const + { + return (name == other.name) && (scope == other.scope); + } + + inline std::string toString() const + { + switch (scope) + { + case SCOPE_LOCAL: + return name + std::string(" (") + LLTrans::getString("Local") + std::string(")"); + break; + case SCOPE_REGION: + return name + std::string(" (") + LLTrans::getString("Region") + std::string(")"); + break; + default: + return name + " (?)"; + } + } +}; + +/// WindLight parameter manager class - what controls all the wind light shaders +class LLWLParamManager : public LLSingleton +{ +public: /// load a preset file void loadPresets(const std::string & fileName); /// save the preset file + // the implementation of this method was unmaintained and is commented out + // *NOTE test and sanity-check before uncommenting and using! void savePresets(const std::string & fileName); /// load an individual preset into the sky - void loadPreset(const std::string & name,bool propogate=true); + void loadPreset(const LLWLParamKey key, bool propogate=true); + + /// load an individual preset from a stream of XML + void loadPresetFromXML(const LLWLParamKey key, std::istream & presetXML); /// save the parameter presets to file - void savePreset(const std::string & name); + void savePreset(const LLWLParamKey key); /// Set shader uniforms dirty, so they'll update automatically. void propagateParameters(void); @@ -161,36 +254,38 @@ public: /// get the radius of the dome inline F32 getDomeRadius(void) const; - - /// Perform global initialization for this class. - static void initClass(void); - - // Cleanup of global data that's only inited once per class. - static void cleanupClass(); - /// add a param to the list - bool addParamSet(const std::string& name, LLWLParamSet& param); + /// add a param set (preset) to the list + bool addParamSet(const LLWLParamKey& key, LLWLParamSet& param); - /// add a param to the list - BOOL addParamSet(const std::string& name, LLSD const & param); + /// add a param set (preset) to the list + BOOL addParamSet(const LLWLParamKey& key, LLSD const & param); - /// get a param from the list - bool getParamSet(const std::string& name, LLWLParamSet& param); + /// get a param set (preset) from the list + bool getParamSet(const LLWLParamKey& key, LLWLParamSet& param); /// set the param in the list with a new param - bool setParamSet(const std::string& name, LLWLParamSet& param); + bool setParamSet(const LLWLParamKey& key, LLWLParamSet& param); /// set the param in the list with a new param - bool setParamSet(const std::string& name, LLSD const & param); - + bool setParamSet(const LLWLParamKey& key, LLSD const & param); + /// gets rid of a parameter and any references to it - /// returns true if successful - bool removeParamSet(const std::string& name, bool delete_from_disk); + /// ignores "delete_from_disk" if the scope is not local + void removeParamSet(const LLWLParamKey& key, bool delete_from_disk); - // singleton pattern implementation - static LLWLParamManager * instance(); + /// clear parameter mapping of a given scope + void clearParamSetsOfScope(LLEnvKey::EScope scope); -public: + /// add all skies in LLSD using the given scope + void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map); + + // returns all skies referenced by the current day cycle (in mDay), with their final names + // side effect: applies changes to all internal structures! (trashes all unreferenced skies in scope, keys in day cycle rescoped to scope, etc.) + std::map finalizeFromDayCycle(LLWLParamKey::EScope scope); + + // returns all skies in map (intended to be called with output from a finalize) + LLSD createSkyMap(std::map map); // helper variables LLWLAnimator mAnimator; @@ -244,13 +339,13 @@ public: F32 mDomeRadius; // list of all the parameters, listed by name - std::map mParamList; - + std::map mParamList; private: - // our parameter manager singleton instance - static LLWLParamManager * sInstance; - + friend class LLSingleton; + /*virtual*/ void initSingleton(); + LLWLParamManager(); + ~LLWLParamManager(); }; inline F32 LLWLParamManager::getDomeOffset(void) const diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index cf06766d73..a027d635e6 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -31,6 +31,7 @@ #include "llfloaterwindlight.h" #include "llwlparammanager.h" +#include "llglslshader.h" #include "lluictrlfactory.h" #include "llsliderctrl.h" @@ -94,7 +95,7 @@ void LLWLParamSet::update(LLGLSLShader * shader) const shader->uniform4fv(param, 1, val.mV); } - else + else // param is the uniform name { LLVector4 val; @@ -119,7 +120,6 @@ void LLWLParamSet::update(LLGLSLShader * shader) const val.mV[0] = i->second.asBoolean(); } - shader->uniform4fv(param, 1, val.mV); } } @@ -260,7 +260,6 @@ void LLWLParamSet::setEastAngle(float val) void LLWLParamSet::mix(LLWLParamSet& src, LLWLParamSet& dest, F32 weight) { // set up the iterators - LLSD::map_iterator cIt = mParamValues.beginMap(); // keep cloud positions and coverage the same /// TODO masking will do this later @@ -273,55 +272,39 @@ void LLWLParamSet::mix(LLWLParamSet& src, LLWLParamSet& dest, F32 weight) LLSD srcVal; LLSD destVal; - // do the interpolation for all the ones saved as vectors - // skip the weird ones - for(; cIt != mParamValues.endMap(); cIt++) { + // Iterate through values + for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) + { - // check params to make sure they're actually there - if(src.mParamValues.has(cIt->first)) + // If param exists in both src and dest, set the holder variables, otherwise skip + if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) { - srcVal = src.mParamValues[cIt->first]; + srcVal = src.mParamValues[iter->first]; + destVal = dest.mParamValues[iter->first]; } else { continue; } - if(dest.mParamValues.has(cIt->first)) + if(iter->second.isReal()) // If it's a real, interpolate directly { - destVal = dest.mParamValues[cIt->first]; + iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); } - else - { - continue; - } - - // skip if not a vector - if(!cIt->second.isArray()) - { - continue; - } - - // only Real vectors allowed - if(!cIt->second[0].isReal()) + else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those + && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) { - continue; + // Actually do interpolation: old value + (difference in values * factor) + for(int i=0; i < iter->second.size(); ++i) + { + // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation + iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); + } } - - // make sure all the same size - if( cIt->second.size() != srcVal.size() || - cIt->second.size() != destVal.size()) + else // Else, skip { continue; - } - - // more error checking might be necessary; - - for(int i=0; i < cIt->second.size(); ++i) - { - cIt->second[i] = (1.0f - weight) * (F32) srcVal[i].asReal() + - weight * (F32) destVal[i].asReal(); - } + } } // now mix the extra parameters diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h index 487e2bf922..1358502032 100644 --- a/indra/newview/llwlparamset.h +++ b/indra/newview/llwlparamset.h @@ -32,10 +32,10 @@ #include "v4math.h" #include "v4color.h" -#include "llviewershadermgr.h" class LLFloaterWindLight; class LLWLParamSet; +class LLGLSLShader; /// A class representing a set of parameter values for the WindLight shaders. class LLWLParamSet { diff --git a/indra/newview/tests/lldir_stub.cpp b/indra/newview/tests/lldir_stub.cpp new file mode 100644 index 0000000000..6646860b5e --- /dev/null +++ b/indra/newview/tests/lldir_stub.cpp @@ -0,0 +1,45 @@ +/** + * @file lldir_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Use me only if you need to stub out some helper functions, not if you e.g. need sane numbers from countFilesInDir + +LLDir::LLDir() {} +LLDir::~LLDir() {} +BOOL LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) { return true; } +void LLDir::setChatLogsDir(const std::string &path) {} +void LLDir::setPerAccountChatLogsDir(const std::string &first, const std::string &last) {} +void LLDir::setLindenUserDir(const std::string &first, const std::string &last) {} +void LLDir::setSkinFolder(const std::string &skin_folder) {} +bool LLDir::setCacheDir(const std::string &path) { return true; } +void LLDir::dumpCurrentDirectories() {} + +class LLDir_stub : public LLDir +{ +public: + LLDir_stub() {} + ~LLDir_stub() {} + + /*virtual*/ void initAppDirs(const std::string &app_name) {} + + /*virtual*/ std::string getCurPath() { return "CUR_PATH_FROM_LLDIR"; } + /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask) { return 42; } + /*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) { fname = fname + "_NEXT"; return false; } + /*virtual*/ void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) { fname = "RANDOM_FILE"; } + /*virtual*/ BOOL fileExists(const std::string &filename) const { return false; } +}; + +LLDir_stub gDirUtil; + +LLDir* gDirUtilp = &gDirUtil; + +std::string LLDir::getExpandedFilename(ELLPath loc, const std::string& subdir, const std::string& filename) const +{ + return subdir + " --- " + filename + " --- expanded!"; +} + diff --git a/indra/newview/tests/llfloaterdaycycle_stub.cpp b/indra/newview/tests/llfloaterdaycycle_stub.cpp new file mode 100644 index 0000000000..e6b145bcfc --- /dev/null +++ b/indra/newview/tests/llfloaterdaycycle_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llfloaterdaycycle_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLFloaterDayCycle +{ +public: + static bool isOpen(void); + static LLFloaterDayCycle* instance(void); + static void syncMenu(void); +}; + +bool LLFloaterDayCycle::isOpen() { return true; } +LLFloaterDayCycle* LLFloaterDayCycle::instance() { return NULL; } +void LLFloaterDayCycle::syncMenu(void) {} diff --git a/indra/newview/tests/llfloaterenvsettings_stub.cpp b/indra/newview/tests/llfloaterenvsettings_stub.cpp new file mode 100644 index 0000000000..e9e792521f --- /dev/null +++ b/indra/newview/tests/llfloaterenvsettings_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llfloaterenvsettings_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLFloaterEnvSettings +{ +public: + static bool isOpen(void); + static LLFloaterEnvSettings* instance(void); + void syncMenu(void); +}; + +bool LLFloaterEnvSettings::isOpen() { return true; } +LLFloaterEnvSettings* LLFloaterEnvSettings::instance() { return NULL; } +void LLFloaterEnvSettings::syncMenu(void) {} diff --git a/indra/newview/tests/llfloaterwindlight_stub.cpp b/indra/newview/tests/llfloaterwindlight_stub.cpp new file mode 100644 index 0000000000..f1891eaf21 --- /dev/null +++ b/indra/newview/tests/llfloaterwindlight_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llfloaterwindlight_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLFloaterWindLight +{ +public: + static bool isOpen(void); + static LLFloaterWindLight* instance(void); + void syncMenu(void); +}; + +bool LLFloaterWindLight::isOpen() { return true; } +LLFloaterWindLight* LLFloaterWindLight::instance() { return NULL; } +void LLFloaterWindLight::syncMenu(void) {} diff --git a/indra/newview/tests/llglslshader_stub.cpp b/indra/newview/tests/llglslshader_stub.cpp new file mode 100644 index 0000000000..5333c8a361 --- /dev/null +++ b/indra/newview/tests/llglslshader_stub.cpp @@ -0,0 +1,22 @@ +/** + * @file llglslshader_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#include "llglslshader.h" + +void LLGLSLShader::uniform1f(const std::string& uniform, F32 num) +{ +} + +void LLGLSLShader::uniform3fv(const std::string& uniform, U32 count, const GLfloat *v) +{ +} + +void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) +{ +} diff --git a/indra/newview/tests/llpipeline_stub.cpp b/indra/newview/tests/llpipeline_stub.cpp new file mode 100644 index 0000000000..85bf0ae3fb --- /dev/null +++ b/indra/newview/tests/llpipeline_stub.cpp @@ -0,0 +1,15 @@ +/** + * @file llpipeline_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLPipeline +{ +public: BOOL canUseWindLightShaders() const; +}; +BOOL LLPipeline::canUseWindLightShaders() const {return TRUE;} +LLPipeline gPipeline; diff --git a/indra/newview/tests/llsky_stub.cpp b/indra/newview/tests/llsky_stub.cpp new file mode 100644 index 0000000000..35f4944a95 --- /dev/null +++ b/indra/newview/tests/llsky_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llsky_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLSky +{ +public: + void setOverrideSun(BOOL override); + void setSunDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity); +}; + +void LLSky::setOverrideSun(BOOL override) {} +void LLSky::setSunDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity) {} + +LLSky gSky; diff --git a/indra/newview/tests/llviewershadermgr_stub.cpp b/indra/newview/tests/llviewershadermgr_stub.cpp new file mode 100644 index 0000000000..0dae527035 --- /dev/null +++ b/indra/newview/tests/llviewershadermgr_stub.cpp @@ -0,0 +1,33 @@ +/** + * @file llglslshader_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#include "../llviewershadermgr.h" + +LLShaderMgr::LLShaderMgr() {} +LLShaderMgr::~LLShaderMgr() {} + +LLViewerShaderMgr::LLViewerShaderMgr() {} +LLViewerShaderMgr::~LLViewerShaderMgr() {} + +LLViewerShaderMgr* stub_instance = NULL; + +LLViewerShaderMgr* LLViewerShaderMgr::instance() { + if(NULL == stub_instance) + { + stub_instance = new LLViewerShaderMgr(); + } + + return stub_instance; +} +LLViewerShaderMgr::shader_iter fake_iter; +LLViewerShaderMgr::shader_iter LLViewerShaderMgr::beginShaders() const {return fake_iter;} +LLViewerShaderMgr::shader_iter LLViewerShaderMgr::endShaders() const {return fake_iter;} + +void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader* shader) {return;} +std::string LLViewerShaderMgr::getShaderDirPrefix() {return "SHADER_DIR_PREFIX-";} diff --git a/indra/newview/tests/llwlanimator_stub.cpp b/indra/newview/tests/llwlanimator_stub.cpp new file mode 100644 index 0000000000..4d1bb85544 --- /dev/null +++ b/indra/newview/tests/llwlanimator_stub.cpp @@ -0,0 +1,12 @@ +/** + * @file llwlanimator_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +LLWLAnimator::LLWLAnimator(void) {} +void LLWLAnimator::update(LLWLParamSet& set) {} +void LLWLAnimator::setTrack(std::map& track, F32 dayRate, F64 dayTime, bool run) {} diff --git a/indra/newview/tests/llwldaycycle_stub.cpp b/indra/newview/tests/llwldaycycle_stub.cpp new file mode 100644 index 0000000000..d98c9614b4 --- /dev/null +++ b/indra/newview/tests/llwldaycycle_stub.cpp @@ -0,0 +1,35 @@ +/** + * @file llwldaycycle_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +LLWLDayCycle::LLWLDayCycle(void) +{ +} + +LLWLDayCycle::~LLWLDayCycle(void) +{ +} + +bool LLWLDayCycle::getKeytime(LLWLParamKey keyFrame, F32& keyTime) +{ + keyTime = 0.5; + return true; +} + +bool LLWLDayCycle::removeKeyframe(F32 time) +{ + return true; +} + +void LLWLDayCycle::loadDayCycleFromFile(const std::string& fileName) +{ +} + +void LLWLDayCycle::removeReferencesTo(const LLWLParamKey &keyframe) +{ +} diff --git a/indra/newview/tests/llwlparammanager_test.cpp b/indra/newview/tests/llwlparammanager_test.cpp new file mode 100644 index 0000000000..3d31567335 --- /dev/null +++ b/indra/newview/tests/llwlparammanager_test.cpp @@ -0,0 +1,257 @@ +/** + * @file llwlparammanager_test.cpp + * @brief LLWLParamManager tests + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled headers +#include "../llviewerprecompiledheaders.h" + +// Class to test +#include "../llwlparammanager.h" + +// Dependencies +#include "linden_common.h" + +// TUT header +#include "lltut.h" + +// Stubs +#include "llwldaycycle_stub.cpp" +#include "llwlparamset_stub.cpp" +#include "llwlanimator_stub.cpp" +#include "llglslshader_stub.cpp" +#include "lldir_stub.cpp" +#include "llsky_stub.cpp" +#include "llfloaterdaycycle_stub.cpp" +#include "llfloaterenvsettings_stub.cpp" +#include "llfloaterwindlight_stub.cpp" +#include "llpipeline_stub.cpp" +#include "llviewershadermgr_stub.cpp" + +void assert_glerror(void) {} +LLViewerCamera::LLViewerCamera() {} +void LLViewerCamera::setView(F32 vertical_fov_rads) {} +std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return std::string(""); } + +char* curl_unescape(const char* c_str, int length) +{ + char* copy = new char[length+4]; + memcpy(copy, c_str, length); + copy[length+0] = 'E'; + copy[length+1] = 'S'; + copy[length+2] = 'C'; + copy[length+3] = '\0'; + return copy; +} +void curl_free(void* p) {delete[] ((char*)p);} +char* curl_escape(const char* c_str, int length) { + char* copy = new char[length+6]; + memcpy(copy, c_str, length); + copy[length+0] = 'U'; + copy[length+1] = 'N'; + copy[length+2] = 'E'; + copy[length+3] = 'S'; + copy[length+4] = 'C'; + copy[length+5] = '\0'; + return copy; +} + +namespace tut +{ + // Main Setup + struct LLWLParamManagerFixture + { + class LLWLParamManagerTest + { + }; + + LLWLParamManager* mTestManager; + + LLWLParamManagerFixture() + : mTestManager(LLWLParamManager::getInstance()) + { + } + + ~LLWLParamManagerFixture() + { + } + }; + typedef test_group factory; + typedef factory::object object; + factory tf("LLWLParamManager test"); + + // Tests + template<> template<> + void object::test<1>() + { + try + { + std::string preset = + "\ + \ + ambient\ + \ + 1.0499999523162842\ + 1.0499999523162842\ + 1.0499999523162842\ + 0.34999999403953552\ + \ + blue_density\ + \ + 0.2447581488182351\ + 0.44872328639030457\ + 0.75999999046325684\ + 0.38000004053115788\ + \ + blue_horizon\ + \ + 0.49548382097675159\ + 0.49548381382419748\ + 0.63999999284744291\ + 0.31999999642372146\ + \ + cloud_color\ + \ + 0.40999999165535073\ + 0.40999999165535073\ + 0.40999999165535073\ + 0.40999999165535073\ + \ + cloud_pos_density1\ + \ + 1.6884100437164307\ + 0.52609699964523315\ + 0.99999999999999289\ + 1\ + \ + cloud_pos_density2\ + \ + 1.6884100437164307\ + 0.52609699964523315\ + 0.125\ + 1\ + \ + cloud_scale\ + \ + 0.4199999868869746\ + 0\ + 0\ + 1\ + \ + cloud_scroll_rate\ + \ + 10.199999809265137\ + 10.01099967956543\ + \ + cloud_shadow\ + \ + 0.26999998092651367\ + 0\ + 0\ + 1\ + \ + density_multiplier\ + \ + 0.00017999998817685818\ + 0\ + 0\ + 1\ + \ + distance_multiplier\ + \ + 0.80000001192093606\ + 0\ + 0\ + 1\ + \ + east_angle\ + 0\ + enable_cloud_scroll\ + \ + 1\ + 1\ + \ + gamma\ + \ + 1\ + 0\ + 0\ + 1\ + \ + glow\ + \ + 5\ + 0.0010000000474974513\ + -0.47999998927116394\ + 1\ + \ + haze_density\ + \ + 0.69999998807907104\ + 0\ + 0\ + 1\ + \ + haze_horizon\ + \ + 0.18999999761581243\ + 0.19915600121021271\ + 0.19915600121021271\ + 1\ + \ + lightnorm\ + \ + 0\ + 0.70710659027099609\ + -0.70710694789886475\ + 0\ + \ + max_y\ + \ + 1605\ + 0\ + 0\ + 1\ + \ + preset_num\ + 22\ + star_brightness\ + 0\ + sun_angle\ + 2.3561947345733643\ + sunlight_color\ + \ + 0.73421055078505759\ + 0.78157895803450828\ + 0.89999997615813498\ + 0.29999998211860301\ + \ + \ + "; + + std::stringstream preset_stream(preset); + mTestManager->loadPresetFromXML(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), preset_stream); + LLWLParamSet dummy; + ensure("Couldn't get ParamSet after loading it", mTestManager->getParamSet(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), dummy)); + } + catch (...) + { + fail("loadPresetFromXML test crashed!"); + } + } + + template<> template<> + void object::test<2>() + { + mTestManager->propagateParameters(); + ensure_equals("Wrong value from getDomeOffset()", mTestManager->getDomeOffset(), 0.96f); + ensure_equals("Wrong value from getDomeRadius()", mTestManager->getDomeRadius(), 15000.f); + ensure_equals("Wrong value from getLightDir()", mTestManager->getLightDir(), LLVector4(-0,0,1,0)); + ensure_equals("Wrong value from getClampedLightDir()", mTestManager->getClampedLightDir(), LLVector4(-0,0,1,0)); + ensure_equals("Wrong value from getRotatedLightDir()", mTestManager->getRotatedLightDir(), LLVector4(0,0,0,1)); + } +} diff --git a/indra/newview/tests/llwlparamset_stub.cpp b/indra/newview/tests/llwlparamset_stub.cpp new file mode 100644 index 0000000000..6ce4b5827d --- /dev/null +++ b/indra/newview/tests/llwlparamset_stub.cpp @@ -0,0 +1,24 @@ +/** + * @file llwlparamset_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +LLWLParamSet::LLWLParamSet(void) +{ +} + +void LLWLParamSet::updateCloudScrolling() +{ +} + +void LLWLParamSet::set(const std::string& name, const LLVector4& val) +{ +} + +void LLWLParamSet::update(LLGLSLShader *shader) const +{ +} -- cgit v1.2.3 From 2fb337bc12984f9abecfbc7f3918c372a7b5ac6c Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Thu, 30 Sep 2010 23:21:23 -0400 Subject: STORM-1126 WIP Windlight Estate Settings port from 1.23: second pass at getting windlight ported to V2. Lots of cleanup in the floater classes. Not sure every decision was correct but it compiles now. Doesn't link yet. (resubmitted by Vadim ProductEngine) --- indra/newview/llappviewer.cpp | 1 - indra/newview/lldrawpoolwater.cpp | 4 +- indra/newview/llenvmanager.cpp | 8 +- indra/newview/llfloaterdaycycle.cpp | 27 +- indra/newview/llfloaterdaycycle.h | 2 +- indra/newview/llfloaterenvsettings.cpp | 25 +- indra/newview/llfloaterenvsettings.h | 2 +- indra/newview/llfloaterregioninfo.cpp | 17 +- indra/newview/llfloaterregioninfo.h | 4 +- indra/newview/llfloaterwater.cpp | 44 +- indra/newview/llfloaterwater.h | 8 + indra/newview/llfloaterwindlight.cpp | 28 +- indra/newview/llfloaterwindlight.h | 2 +- indra/newview/llviewermenu.cpp | 2 +- indra/newview/llviewerregion.cpp | 5 - indra/newview/llviewerregion.h | 5 - indra/newview/llwaterparammanager.cpp | 9 +- indra/newview/llwlanimator.cpp | 2 +- indra/newview/llwldaycycle.cpp | 3 +- indra/newview/llwlhandlers.cpp | 7 +- indra/newview/llwlhandlers.h | 1 + indra/newview/llwlparammanager.cpp | 8 +- .../default/xui/en/floater_day_cycle_options.xml | 804 +++------ .../skins/default/xui/en/floater_env_settings.xml | 231 +-- .../default/xui/en/floater_windlight_options.xml | 1874 ++++++-------------- 25 files changed, 1041 insertions(+), 2082 deletions(-) (limited to 'indra') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 333c92e50d..aa781122ce 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1471,7 +1471,6 @@ bool LLAppViewer::cleanup() LLViewerObject::cleanupVOClasses(); LLWaterParamManager::cleanupClass(); - LLWLParamManager::cleanupClass(); LLPostProcess::cleanupClass(); LLTracker::cleanupInstance(); diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index ce1b899d55..213b95b119 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -103,7 +103,7 @@ void LLDrawPoolWater::prerender() // got rid of modulation by light color since it got a little too // green at sunset and sl-57047 (underwater turns black at 8:00) - sWaterFogColor = LLWaterParamManager::instance()->getFogColor(); + sWaterFogColor = LLWaterParamManager::instance().getFogColor(); sWaterFogColor.mV[3] = 0; } @@ -433,7 +433,7 @@ void LLDrawPoolWater::shade() //bind normal map S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); // change mWaterNormp if needed if (mWaterNormp->getID() != param_mgr->getNormalMapID()) diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index f551aa6c8a..a257e4ea24 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -37,6 +37,7 @@ #include "llagent.h" #include "llviewerregion.h" +#include "llfloaterreg.h" #include "llfloaterwindlight.h" #include "llfloaterwater.h" #include "llfloaterenvsettings.h" @@ -45,6 +46,7 @@ #include "llfloaterregioninfo.h" #include "llwindlightscrubbers.h" #include "llwlhandlers.h" +#include "llnotifications.h" extern LLControlGroup gSavedSettings; @@ -78,7 +80,7 @@ void LLEnvManager::changedRegion(bool interp) mInterpNextChangeMessage = interp; mPendingOutgoingMessage = false; - LLFloaterEnvSettings::instance()->close(); + LLFloaterEnvSettings::instance()->closeFloater(); resetInternalsToDefault(LLEnvKey::SCOPE_REGION); @@ -144,7 +146,7 @@ void LLEnvManager::maybeClearEditingScope(bool user_initiated, bool was_commit) } else { - LLNotifications::instance().add("EnvEditExternalCancel", LLSD()); + LLNotifications::instance().add("EnvEditExternalCancel", LLSD(), LLSD()); } } @@ -160,7 +162,7 @@ void LLEnvManager::clearEditingScope(const LLSD& notification, const LLSD& respo { // *TODO: select terrain panel here mIsEditing = false; - LLFloaterRegionInfo::showInstance(); + LLFloaterReg::showTypedInstance("regioninfo"); return; } diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index efaac5cfc5..48f91aa64a 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -47,6 +47,7 @@ #include "llcombobox.h" #include "lllineeditor.h" #include "llwlanimator.h" +#include "llnotifications.h" #include "v4math.h" #include "llviewerdisplay.h" @@ -59,6 +60,7 @@ #include "llfloaterwindlight.h" #include "llwindlightscrubbers.h" #include "llenvmanager.h" +#include "llfloaterreg.h" LLFloaterDayCycle* LLFloaterDayCycle::sDayCycle = NULL; const F32 LLFloaterDayCycle::sHoursPerDay = 24.0f; @@ -67,13 +69,12 @@ LLEnvKey::EScope LLFloaterDayCycle::sScope; std::string LLFloaterDayCycle::sOriginalTitle; LLWLAnimator::ETime LLFloaterDayCycle::sPreviousTimeType = LLWLAnimator::TIME_LINDEN; -LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater(std::string("Day Cycle Floater")) +LLFloaterDayCycle::LLFloaterDayCycle(const LLSD &key) : LLFloater(key) { - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_day_cycle_options.xml", NULL, FALSE); sOriginalTitle = getTitle(); - llassert(MAX_LOCAL_KEY_FRAMES <= getChild("WLDayCycleKeys")->getMaxSliderCount() && - MAX_REGION_KEYFRAMES <= getChild("WLDayCycleKeys")->getMaxSliderCount()); + llassert(LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES <= getChild("WLDayCycleKeys")->getMaxValue() && + LLWLPacketScrubber::MAX_REGION_KEY_FRAMES <= getChild("WLDayCycleKeys")->getMaxValue()); // add the time slider LLMultiSliderCtrl* sldr = getChild("WLTimeSlider"); @@ -90,10 +91,8 @@ LLFloaterDayCycle::~LLFloaterDayCycle() void LLFloaterDayCycle::onClickHelp(void* data) { - LLFloaterDayCycle* self = LLFloaterDayCycle::instance(); - std::string xml_alert = *(std::string *) data; - LLNotifications::instance().add(self->contextualNotification(xml_alert)); + LLNotifications::instance().add(xml_alert, LLSD(), LLSD()); } void LLFloaterDayCycle::initHelpBtn(const std::string& name, const std::string& xml_alert) @@ -244,7 +243,7 @@ LLFloaterDayCycle* LLFloaterDayCycle::instance() { if (!sDayCycle) { - sDayCycle = new LLFloaterDayCycle(); + sDayCycle = new LLFloaterDayCycle("Day Cycle Floater"); // sDayCycle->open(); // sDayCycle->setFocus(TRUE); } @@ -265,7 +264,7 @@ void LLFloaterDayCycle::show(LLEnvKey::EScope scope) LLFloaterDayCycle* dayCycle = instance(); if(scope != sScope && ((LLView*)dayCycle)->getVisible()) { - LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD()); + LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD(), LLSD()); return; } sScope = scope; @@ -286,7 +285,7 @@ void LLFloaterDayCycle::show(LLEnvKey::EScope scope) //LLUICtrlFactory::getInstance()->buildFloater(dayCycle, "floater_day_cycle_options.xml"); //dayCycle->initCallbacks(); - dayCycle->open(); + dayCycle->openFloater(); } // virtual @@ -537,16 +536,16 @@ void LLFloaterDayCycle::onAddKey(void* userData) max_sliders = LLWLPacketScrubber::MAX_REGION_KEY_FRAMES; break; default: - max_sliders = kSldr->getMaxSliderCount(); + max_sliders = (S32)kSldr->getMaxValue(); break; } - if(kSldr->getSliderCount() >= max_sliders) + if(kSldr->getValue().asInteger() >= max_sliders) { LLSD args; args["SCOPE"] = LLEnvManager::getScopeString(sScope); args["MAX"] = max_sliders; - LLNotifications::instance().add("DayCycleTooManyKeyframes", args); + LLNotifications::instance().add("DayCycleTooManyKeyframes", LLSD(), args); return; } @@ -608,7 +607,7 @@ void LLFloaterDayCycle::onDeleteKey(void* userData) } else if(sSliderToKey.size() == 1) { - LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD()); + LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD(), LLSD()); return; } diff --git a/indra/newview/llfloaterdaycycle.h b/indra/newview/llfloaterdaycycle.h index 1c021f0c6a..246a0357ba 100644 --- a/indra/newview/llfloaterdaycycle.h +++ b/indra/newview/llfloaterdaycycle.h @@ -59,7 +59,7 @@ public: class LLFloaterDayCycle : public LLFloater { public: - LLFloaterDayCycle(); + LLFloaterDayCycle(const LLSD &key); virtual ~LLFloaterDayCycle(); // map of sliders to parameters diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index 6d1b27db07..eea333745f 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -43,6 +43,7 @@ #include "llcombobox.h" #include "llcolorswatch.h" #include "llwlanimator.h" +#include "llnotifications.h" #include "llwlparamset.h" #include "llwlparammanager.h" @@ -59,10 +60,8 @@ LLFloaterEnvSettings* LLFloaterEnvSettings::sEnvSettings = NULL; -LLFloaterEnvSettings::LLFloaterEnvSettings() : LLFloater(std::string("Environment Settings Floater")) -{ - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_env_settings.xml", NULL, FALSE); - +LLFloaterEnvSettings::LLFloaterEnvSettings(const LLSD &key) : LLFloater(key) +{ // load it up initCallbacks(); } @@ -73,8 +72,7 @@ LLFloaterEnvSettings::~LLFloaterEnvSettings() void LLFloaterEnvSettings::onClickHelp(void* data) { - LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data; - LLNotifications::instance().add(self->contextualNotification("EnvSettingsHelpButton")); + LLNotifications::instance().add("EnvSettingsHelpButton", LLSD(), LLSD()); } void LLFloaterEnvSettings::onUseRegionEnvironment(LLUICtrl* ctrl, void* data) @@ -212,7 +210,7 @@ LLFloaterEnvSettings* LLFloaterEnvSettings::instance() { if (!sEnvSettings) { - sEnvSettings = new LLFloaterEnvSettings(); + sEnvSettings = new LLFloaterEnvSettings("Environment Editor Floater"); // sEnvSettings->open(); // sEnvSettings->setFocus(TRUE); } @@ -237,9 +235,9 @@ void LLFloaterEnvSettings::setControlsEnabled(bool enable) else { // disable UI elements the user shouldn't be able to see to protect potentially proprietary WL region settings from being visible - LLFloaterWindLight::instance()->close(); - LLFloaterWater::instance()->close(); - LLFloaterDayCycle::instance()->close(); + LLFloaterWindLight::instance()->closeFloater(); + LLFloaterWater::instance()->closeFloater(); + LLFloaterDayCycle::instance()->closeFloater(); childDisable("EnvAdvancedSkyButton"); childDisable("EnvAdvancedWaterButton"); childDisable("EnvUseEstateTimeButton"); @@ -267,9 +265,10 @@ void LLFloaterEnvSettings::show() sEnvSettings->childSetVisible("RegionWLOptIn", LLEnvManager::getInstance()->regionCapable()); sEnvSettings->setOptIn(opt_in); - sEnvSettings->getChildView("RegionWLOptIn")->setValue(LLSD::Boolean(opt_in)); + LLCheckBoxCtrl* checkbox = (LLCheckBoxCtrl*)envSettings->getChildView("RegionWLOptIn"); + checkbox->setValue(LLSD::Boolean(opt_in)); sEnvSettings->getChildView("RegionWLOptIn")->setToolTip(sEnvSettings->getString("region_environment_tooltip")); - envSettings->open(); + envSettings->openFloater(); } bool LLFloaterEnvSettings::isOpen() @@ -361,7 +360,7 @@ void LLFloaterEnvSettings::onOpenAdvancedSky(void* userData) void LLFloaterEnvSettings::onOpenAdvancedWater(void* userData) { - LLFloaterWater::show(); + LLFloaterWater::instance()->openFloater(); } diff --git a/indra/newview/llfloaterenvsettings.h b/indra/newview/llfloaterenvsettings.h index 0bf3e48676..54611a81c3 100644 --- a/indra/newview/llfloaterenvsettings.h +++ b/indra/newview/llfloaterenvsettings.h @@ -45,7 +45,7 @@ class LLFloaterEnvSettings : public LLFloater { public: - LLFloaterEnvSettings(); + LLFloaterEnvSettings(const LLSD &key); virtual ~LLFloaterEnvSettings(); /// initialize all the callbacks for the menu diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index f6377d50fa..7617b98f20 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -51,6 +51,7 @@ #include "llcombobox.h" #include "llenvmanager.h" #include "llfilepicker.h" +#include "llfloaterdaycycle.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() #include "llfloatertopobjects.h" // added to fix SL-32336 #include "llfloatergroups.h" @@ -1167,7 +1168,7 @@ LLPanelRegionTerrainInfo* LLPanelRegionTerrainInfo::instance() } // virtual -void LLPanelRegionTerrainInfo::close(bool app_quitting) +void LLPanelRegionTerrainInfo::closeFloater(bool app_quitting) { if (sPanelRegionTerrainInfo) { @@ -1407,7 +1408,7 @@ void LLPanelRegionTerrainInfo::onOpenAdvancedSky(void* userData) void LLPanelRegionTerrainInfo::onOpenAdvancedWater(void* userData) { - LLFloaterWater::show(LLEnvKey::SCOPE_REGION); + LLFloaterWater::instance()->show(LLEnvKey::SCOPE_REGION); } @@ -1449,9 +1450,9 @@ void LLPanelRegionTerrainInfo::onSetRegionToDefaultWL(void* userData) void LLPanelRegionTerrainInfo::cancelChanges() { - LLFloaterWindLight::instance()->close(); - LLFloaterWater::instance()->close(); - LLFloaterDayCycle::instance()->close(); + LLFloaterWindLight::instance()->closeFloater(); + LLFloaterWater::instance()->closeFloater(); + LLFloaterDayCycle::instance()->closeFloater(); // disable commmit and cancel LLPanelRegionTerrainInfo::instance()->setCommitControls(false); @@ -2130,14 +2131,14 @@ bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) return rv; } -void LLFloaterRegionInfo::close(bool app_quitting) +void LLFloaterRegionInfo::closeFloater(bool app_quitting) { if(!app_quitting) { LLEnvManager::getInstance()->maybeClearEditingScope(true, false); - LLPanelRegionTerrainInfo::close(app_quitting); + LLPanelRegionTerrainInfo::closeFloater(app_quitting); } - LLFloater::close(app_quitting); + LLFloater::closeFloater(app_quitting); } void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl) diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 2fdec5a944..b1f7e88d33 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -73,6 +73,8 @@ public: /*virtual*/ void onOpen(const LLSD& key); /*virtual*/ BOOL postBuild(); + /*virtual*/void closeFloater(bool app_quitting); + static void processEstateOwnerRequest(LLMessageSystem* msg, void**); // get and process region info if necessary. @@ -236,7 +238,7 @@ public: static LLPanelRegionTerrainInfo* instance(); virtual BOOL postBuild(); // LLPanel - static void close(bool app_quitting); + static void closeFloater(bool app_quitting); F32 getSunHour(); virtual bool refreshFromRegion(LLViewerRegion* region); // refresh local settings from region update from simulator diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index a443b788fb..4bc8523d0a 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -45,6 +45,7 @@ #include "llfloaterdaycycle.h" #include "llboost.h" #include "llmultisliderctrl.h" +#include "llnotifications.h" #include "v4math.h" #include "llviewerdisplay.h" @@ -104,6 +105,47 @@ BOOL LLFloaterWater::postBuild() syncMenu(); return TRUE; } + +//static +LLFloaterWater* LLFloaterWater::instance() +{ + if (!sWater) + { + sWater = new LLFloaterWater(LLSD()); + } + return sWater; +} + +void LLFloaterWater::show(LLEnvKey::EScope scope) +{ + LLFloaterWater* water = instance(); + + if(scope != sScope && ((LLView*)water)->getVisible()) + { + LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD(), LLSD()); + return; + } + sScope = scope; + std::string scope_str = ""; + switch(sScope) + { + case LLEnvKey::SCOPE_LOCAL: + scope_str = LLTrans::getString("LocalSettings"); + break; + case LLEnvKey::SCOPE_REGION: + scope_str = LLTrans::getString("RegionSettings"); + break; + } + std::string title = sOriginalTitle + " (" + scope_str + ")"; + water->setTitle(title); + water->syncMenu(); + + LLEnvManager::instance().startEditingScope(scope); + + water->openFloater(); + +} + void LLFloaterWater::initCallbacks(void) { LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); @@ -620,7 +662,7 @@ void LLFloaterWater::onChangePresetName(LLUICtrl* ctrl) std::string data = ctrl->getValue().asString(); if(!data.empty()) { - LLWaterParamManager::instance()->loadPreset(data); + LLWaterParamManager::instance().loadPreset(data); syncMenu(); } } diff --git a/indra/newview/llfloaterwater.h b/indra/newview/llfloaterwater.h index 57fb9745b1..8b3915bfe9 100644 --- a/indra/newview/llfloaterwater.h +++ b/indra/newview/llfloaterwater.h @@ -35,6 +35,7 @@ #include #include "llwlparamset.h" +#include "llenvmanager.h" struct WaterVector2Control; struct WaterVector3Control; @@ -53,6 +54,11 @@ public: /// initialize all void initCallbacks(void); + // one instance only + static LLFloaterWater* instance(); + + void show(LLEnvKey::EScope scope); + bool newPromptCallback(const LLSD& notification, const LLSD& response); /// general purpose callbacks for dealing with color controllers @@ -103,6 +109,8 @@ private: static std::set sDefaultPresets; static LLEnvKey::EScope sScope; static std::string sOriginalTitle; + + static LLFloaterWater* sWater; }; diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index 960a552b3d..d5ba0befec 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -48,6 +48,7 @@ #include "lllineeditor.h" #include "llfloaterdaycycle.h" #include "llboost.h" +#include "llnotifications.h" #include "v4math.h" #include "llviewerdisplay.h" @@ -68,9 +69,8 @@ std::string LLFloaterWindLight::sOriginalTitle; static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -LLFloaterWindLight::LLFloaterWindLight() : LLFloater(std::string("windlight floater")) +LLFloaterWindLight::LLFloaterWindLight(const LLSD &key) : LLFloater(key) { - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_options.xml", NULL, FALSE); sOriginalTitle = getTitle(); // add the combo boxes @@ -207,6 +207,8 @@ void LLFloaterWindLight::initCallbacks(void) { childSetCommitCallback("WLCloudDetailDensity", onColorControlBMoved, ¶m_mgr->mCloudDetail); // Cloud extras + static std::string use_classic_clouds = "SkyUseClassicClouds"; + childSetCommitCallback("WLCloudCoverage", onFloatControlMoved, ¶m_mgr->mCloudCoverage); childSetCommitCallback("WLCloudScale", onFloatControlMoved, ¶m_mgr->mCloudScale); childSetCommitCallback("WLCloudLockX", onCloudScrollXToggled, NULL); @@ -214,7 +216,7 @@ void LLFloaterWindLight::initCallbacks(void) { childSetCommitCallback("WLCloudScrollX", onCloudScrollXMoved, NULL); childSetCommitCallback("WLCloudScrollY", onCloudScrollYMoved, NULL); childSetCommitCallback("WLDistanceMult", onFloatControlMoved, ¶m_mgr->mDistanceMult); - childSetCommitCallback("DrawClassicClouds", LLSavedSettingsGlue::setBOOL, (void*)"SkyUseClassicClouds"); + //childSetCommitCallback("DrawClassicClouds", LLSavedSettingsGlue::setBOOL, (void*)&use_classic_clouds); // WL Top childSetAction("WLDayCycleMenuButton", onOpenDayCycle, NULL); @@ -226,8 +228,7 @@ void LLFloaterWindLight::initCallbacks(void) { childSetAction("WLSavePreset", onSavePreset, comboBox); childSetAction("WLDeletePreset", onDeletePreset, comboBox); - comboBox->setCommitCallback(onChangePresetName); - + //childSetAction("WLPresetsCombo", onChangePresetName, comboBox); // Dome childSetCommitCallback("WLGamma", onFloatControlMoved, ¶m_mgr->mWLGamma); @@ -236,10 +237,8 @@ void LLFloaterWindLight::initCallbacks(void) { void LLFloaterWindLight::onClickHelp(void* data) { - LLFloaterWindLight* self = LLFloaterWindLight::instance(); - const std::string xml_alert = *(std::string*)data; - LLNotifications::instance().add(self->contextualNotification(xml_alert)); + LLNotifications::instance().add(xml_alert, LLSD(), LLSD()); } void LLFloaterWindLight::initHelpBtn(const std::string& name, const std::string& xml_alert) @@ -304,7 +303,7 @@ bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& } else { - LLNotifications::instance().add("ExistsSkyPresetAlert"); + LLNotifications::instance().add("ExistsSkyPresetAlert", LLSD(), LLSD()); } } return false; @@ -448,16 +447,17 @@ LLFloaterWindLight* LLFloaterWindLight::instance() { if (!sWindLight) { - sWindLight = new LLFloaterWindLight(); + sWindLight = new LLFloaterWindLight("WindLight floater"); } return sWindLight; } + void LLFloaterWindLight::show(LLEnvKey::EScope scope) { LLFloaterWindLight* windLight = instance(); if(scope != sScope && ((LLView*)windLight)->getVisible()) { - LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD()); + LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD(), LLSD()); return; } sScope = scope; @@ -481,7 +481,7 @@ void LLFloaterWindLight::show(LLEnvKey::EScope scope) //LLUICtrlFactory::getInstance()->buildFloater(windLight, "floater_windlight_options.xml"); //windLight->initCallbacks(); - windLight->open(); + windLight->openFloater(); } bool LLFloaterWindLight::isOpen() @@ -824,7 +824,7 @@ void LLFloaterWindLight::onSavePreset(void* userData) LLWLParamKey(comboBox->getSelectedValue())); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotifications::instance().add("WLNoEditDefault", LLSD(), LLSD()); return; } @@ -896,7 +896,7 @@ bool LLFloaterWindLight::deleteAlertCallback(const LLSD& notification, const LLS std::set::iterator sIt = sDefaultPresets.find(key); if(sIt != sDefaultPresets.end()) { - LLNotifications::instance().add("WLNoEditDefault"); + LLNotifications::instance().add("WLNoEditDefault", LLSD(), LLSD()); return false; } diff --git a/indra/newview/llfloaterwindlight.h b/indra/newview/llfloaterwindlight.h index c0fea2558c..3b137e601f 100644 --- a/indra/newview/llfloaterwindlight.h +++ b/indra/newview/llfloaterwindlight.h @@ -50,7 +50,7 @@ struct WLFloatControl; class LLFloaterWindLight : public LLFloater { public: - LLFloaterWindLight(); + LLFloaterWindLight(const LLSD &key); virtual ~LLFloaterWindLight(); /// initialize all diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 614eb6ed88..808ab1e344 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7630,7 +7630,7 @@ class LLWorldEnvSettings : public view_listener_t } else if(gSavedSettings.getBOOL("UseEnvironmentFromRegion")) { - LLNotifications::instance().add("EnvLockedUsingRegion", LLSD()); + LLNotifications::instance().add("EnvLockedUsingRegion", LLSD(), LLSD()); } else { diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 0ed254bbc5..9b4c85fb0c 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1495,8 +1495,3 @@ std::string LLViewerRegion::getDescription() const { return stringize(*this); } - -std::string LLViewerRegion::getDescription() const -{ - return stringize(*this); -} diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 307e2cf3a2..284503361a 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -400,11 +400,6 @@ private: LLEventPoll* mEventPoll; - /// Post an event to this LLCapabilityListener to invoke a capability message on - /// this LLViewerRegion's server - /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) - LLCapabilityListener mCapabilityListener; - /// Post an event to this LLCapabilityListener to invoke a capability message on /// this LLViewerRegion's server /// (https://wiki.lindenlab.com/wiki/Viewer:Messaging/Messaging_Notes#Capabilities) diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index c984938303..61a69bdde1 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -78,6 +78,11 @@ LLWaterParamManager::~LLWaterParamManager() { } +LLWaterParamManager::cleanupClass() +{ + // TODO: what needs to be cleaned up? +} + void LLWaterParamManager::loadAllPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); @@ -254,11 +259,11 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) } } -static LLFastTimer::DeclareTimer FTM_UPDATE_WLPARAM("Update Windlight Params"); +static LLFastTimer::DeclareTimer FTM_UPDATE_WATERPARAM("Update Water Params"); void LLWaterParamManager::update(LLViewerCamera * cam) { - LLFastTimer ftm(FTM_UPDATE_WLPARAM); + LLFastTimer ftm(FTM_UPDATE_WATERPARAM); // update the shaders and the menu propagateParameters(); diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp index 2e249b9701..3d51ad89ff 100644 --- a/indra/newview/llwlanimator.cpp +++ b/indra/newview/llwlanimator.cpp @@ -47,7 +47,7 @@ LLWLAnimator::LLWLAnimator() : mStartTime(0.f), mDayRate(1.f), mDayTime(0.f), void LLWLAnimator::update(LLWLParamSet& curParams) { - llassert(mUseLindenTime != mUseLocalTime); + //llassert(mUseLindenTime != mUseLocalTime); F64 curTime; curTime = getDayTime(); diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 52bbb4b5fc..b36fa5c485 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -36,6 +36,7 @@ #include "llsdserialize.h" #include "llwlparammanager.h" #include "llfloaterdaycycle.h" +#include "llnotifications.h" #include "llviewerwindow.h" @@ -84,7 +85,7 @@ void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope // alert the user LLSD args; args["SKY"] = day_data[i][1].asString(); - LLNotifications::instance().add("WLMissingSky", args); + LLNotifications::instance().add("WLMissingSky", LLSD(), args); continue; } } diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index c4f11cf00a..f09692b2b7 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -37,6 +37,7 @@ #include "llagent.h" #include "llviewerregion.h" #include "llenvmanager.h" +#include "llnotifications.h" /**** * LLEnvironmentRequestResponder @@ -108,7 +109,7 @@ bool LLEnvironmentApplyResponder::initiateRequest(const LLSD& content) { LLSD args(LLSD::emptyMap()); args["WAIT"] = (F64)UPDATE_WAIT_SECONDS; - LLNotifications::instance().add("EnvUpdateRate", args); + LLNotifications::instance().add("EnvUpdateRate", LLSD(), args); return false; } @@ -139,7 +140,7 @@ bool LLEnvironmentApplyResponder::initiateRequest(const LLSD& content) LL_WARNS("WindlightCaps") << "Region couldn't apply windlight settings! Reason from sim: " << content["fail_reason"].asString() << LL_ENDL; LLSD args(LLSD::emptyMap()); args["FAIL_REASON"] = content["fail_reason"].asString(); - LLNotifications::instance().add("WLRegionApplyFail", args); + LLNotifications::instance().add("WLRegionApplyFail", LLSD(), args); } LLEnvManager::getInstance()->commitSettingsFinished(LLEnvKey::SCOPE_REGION); @@ -153,7 +154,7 @@ bool LLEnvironmentApplyResponder::initiateRequest(const LLSD& content) LLSD args(LLSD::emptyMap()); args["FAIL_REASON"] = msg.str(); - LLNotifications::instance().add("WLRegionApplyFail", args); + LLNotifications::instance().add("WLRegionApplyFail", LLSD(), args); LLEnvManager::getInstance()->commitSettingsFinished(LLEnvKey::SCOPE_REGION); } diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index a50404f2e1..811dc4bb73 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -34,6 +34,7 @@ #define LL_LLWLHANDLERS_H #include "llviewerprecompiledheaders.h" +#include "llhttpclient.h" class LLEnvManager; diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 493d066942..3070fed81f 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -433,9 +433,11 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) } +static LLFastTimer::DeclareTimer FTM_UPDATE_WLPARAM("Update Windlight Params"); + void LLWLParamManager::propagateParameters(void) { - LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); + LLFastTimer ftm(FTM_UPDATE_WLPARAM); LLVector4 sunDir; LLVector4 moonDir; @@ -459,7 +461,7 @@ void LLWLParamManager::propagateParameters(void) { mLightDir = sunDir; } - else if(sunDir.mV[1] < 0 && sunDir.mV[1] > NIGHTTIME_ELEVATION_COS) + else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); @@ -506,7 +508,7 @@ void LLWLParamManager::propagateParameters(void) void LLWLParamManager::update(LLViewerCamera * cam) { - LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); + LLFastTimer ftm(FTM_UPDATE_WLPARAM); // update clouds, sun, and general mCurParams.updateCloudScrolling(); diff --git a/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml b/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml index 65e2462ef8..84812b9de6 100644 --- a/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml +++ b/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml @@ -1,558 +1,250 @@ - - - - - - - 12am - - - 3am - - - 6am - - - 9am - - - 12pm - - - 3pm - - - 6pm - - - 9pm - - - 12am - - - | - - - I - - - | - - - I - - - | - - - I - - - | - - - I - - - | - - Just a panel - + + + + + - Just a panel 2 - - - - - - + Just a panel + + Date: Tue, 24 May 2011 15:28:20 +0300 Subject: STORM-1256 WIP Improvements to region enviroment settings editing. * Enable/disable controls according to the region permissions. * Update controls when region settings update comes. --- indra/newview/llenvmanager.cpp | 32 +++++++++++++----- indra/newview/llenvmanager.h | 13 +++++++- indra/newview/llfloaterregioninfo.cpp | 63 +++++++++++++++++++++++++++++++---- indra/newview/llfloaterregioninfo.h | 8 +++++ 4 files changed, 100 insertions(+), 16 deletions(-) (limited to 'indra') diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 9f15f9adfc..688e2ea9bf 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -770,6 +770,11 @@ LLSD LLEnvManagerNew::getDayCycleByName(const std::string name) return LLWLDayCycle::loadCycleDataFromFile(name + ".xml"); } +void LLEnvManagerNew::requestRegionSettings() +{ + LLEnvironmentRequest::initiate(); +} + bool LLEnvManagerNew::sendRegionSettings(const LLEnvironmentSettings& new_settings) { LLSD metadata; @@ -781,6 +786,16 @@ bool LLEnvManagerNew::sendRegionSettings(const LLEnvironmentSettings& new_settin return LLEnvironmentApply::initiateRequest(new_settings.makePacket(metadata)); } +boost::signals2::connection LLEnvManagerNew::setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb) +{ + return mRegionSettingsChangeSignal.connect(cb); +} + +boost::signals2::connection LLEnvManagerNew::setRegionChangeCallback(const region_change_signal_t::slot_type& cb) +{ + return mRegionChangeSignal.connect(cb); +} + void LLEnvManagerNew::onRegionCrossing() { LL_DEBUGS("Windlight") << "Crossed region" << LL_ENDL; @@ -798,18 +813,22 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) // If the message was valid, grab the UUID from it and save it for next outbound update message. mLastReceivedID = content[0]["messageID"].asUUID(); - // 1. Refresh cached region settings. + // Refresh cached region settings. LL_DEBUGS("Windlight") << "Caching region environment settings: " << content << LL_ENDL; F32 sun_hour = 0; // *TODO LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); mCachedRegionPrefs = new_settings; - // 2. If using server settings, update managers. + // If using server settings, update managers. if (getUseRegionSettings()) { updateManagersFromPrefs(mInterpNextChangeMessage); } + // Let interested parties know about the region settings update. + mRegionSettingsChangeSignal(); + + // reset mInterpNextChangeMessage = false; } @@ -832,12 +851,6 @@ void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate) LLWLParamManager::instance().applyUserPrefs(interpolate); } -void LLEnvManagerNew::requestRegionSettings() -{ - LLEnvironmentRequest::initiate(); - // *TODO: Indicate that current cached region settings have been invalidated? -} - void LLEnvManagerNew::onRegionChange(bool interpolate) { // Avoid duplicating region setting requests @@ -854,4 +867,7 @@ void LLEnvManagerNew::onRegionChange(bool interpolate) mCurRegionUUID = region_uuid; mInterpNextChangeMessage = interpolate; requestRegionSettings(); + + // Let interested parties know agent region has been changed. + mRegionChangeSignal(); } diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index f52eaf5a4b..eb678e000e 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -259,6 +259,9 @@ class LLEnvManagerNew : public LLSingleton { LOG_CLASS(LLEnvManagerNew); public: + typedef boost::signals2::signal region_settings_change_signal_t; + typedef boost::signals2::signal region_change_signal_t; + LLEnvManagerNew(); // getters to access user env. preferences @@ -293,7 +296,10 @@ public: static LLSD getDayCycleByName(const std::string name); // Misc. + void requestRegionSettings(); bool sendRegionSettings(const LLEnvironmentSettings& new_settings); + boost::signals2::connection setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb); + boost::signals2::connection setRegionChangeCallback(const region_change_signal_t::slot_type& cb); // Public callbacks. void onRegionCrossing(); @@ -305,10 +311,15 @@ private: /*virtual*/ void initSingleton(); void updateManagersFromPrefs(bool interpolate); - void requestRegionSettings(); void onRegionChange(bool interpolate); + /// Emitted when region environment settings update comes. + region_settings_change_signal_t mRegionSettingsChangeSignal; + + /// Emitted when agent region changes. Move to LLAgent? + region_settings_change_signal_t mRegionChangeSignal; + LLEnvPrefs mUserPrefs; /// User environment preferences. LLEnvironmentSettings mCachedRegionPrefs; /// Cached region environment settings. bool mInterpNextChangeMessage; /// Interpolate env. settings on next region change. diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 56025c3143..657dd67035 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -218,6 +218,9 @@ BOOL LLFloaterRegionInfo::postBuild() "EstateOwnerMessage", &processEstateOwnerRequest); + // Request region info when agent region changes. + LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterRegionInfo::requestRegionInfo, this)); + return TRUE; } @@ -292,6 +295,8 @@ void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) // static void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { + LL_DEBUGS("Windlight") << "Processing region info" << LL_ENDL; + LLPanel* panel; LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance("region_info"); llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl; @@ -299,11 +304,12 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { return; } - - - // currently, region can send this message when its windlight settings change - LLEnvManager::instance().refreshFromStorage(LLEnvKey::SCOPE_REGION); + // We need to re-request environment setting here, + // otherwise after we apply (send) updated region settings we won't get them back, + // so our environment won't be updated. + LLEnvManagerNew::instance().requestRegionSettings(); + LLTabContainer* tab = floater->getChild("region_panels"); LLViewerRegion* region = gAgent.getRegion(); @@ -3171,7 +3177,8 @@ bool LLDispatchSetEstateAccess::operator()( } LLPanelEnvironmentInfo::LLPanelEnvironmentInfo() -: mRegionSettingsRadioGroup(NULL), +: mEnableEditing(false), + mRegionSettingsRadioGroup(NULL), mDayCycleSettingsRadioGroup(NULL), mWaterPresetCombo(NULL), mSkyPresetCombo(NULL), @@ -3195,15 +3202,32 @@ BOOL LLPanelEnvironmentInfo::postBuild() childSetCommitCallback("save_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnSave, this), NULL); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); + LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); + return TRUE; } // virtual void LLPanelEnvironmentInfo::onOpen(const LLSD& key) { + LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; refresh(); } +// virtual +bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) +{ + LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; + BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); + BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); + + // Don't refresh from region settings to avoid flicker after applying new region settings. + mEnableEditing = owner_or_god_or_manager; + setControlsEnabled(mEnableEditing); + + return LLPanelRegionInfo::refreshFromRegion(region); +} + void LLPanelEnvironmentInfo::refresh() { populateWaterPresetsList(); @@ -3218,8 +3242,27 @@ void LLPanelEnvironmentInfo::refresh() mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); - LLPanelEnvironmentInfo::onSwitchRegionSettings(); - LLPanelEnvironmentInfo::onSwitchDayCycle(); + setControlsEnabled(mEnableEditing); +} + +void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) +{ + mRegionSettingsRadioGroup->setEnabled(enabled); + mDayCycleSettingsRadioGroup->setEnabled(enabled); + + mWaterPresetCombo->setEnabled(enabled); + mSkyPresetCombo->setEnabled(enabled); + mDayCyclePresetCombo->setEnabled(enabled); + + getChildView("save_btn")->setEnabled(enabled); + getChildView("cancel_btn")->setEnabled(enabled); + + if (enabled) + { + // Enable/disable some controls based on currently selected radio buttons. + LLPanelEnvironmentInfo::onSwitchRegionSettings(); + LLPanelEnvironmentInfo::onSwitchDayCycle(); + } } void LLPanelEnvironmentInfo::populateWaterPresetsList() @@ -3422,3 +3465,9 @@ void LLPanelEnvironmentInfo::onBtnCancel() // Reload current region settings. refresh(); } + +void LLPanelEnvironmentInfo::onRegionSettingschange() +{ + LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; + refresh(); +} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index dc5e250cc4..4dc235ad19 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -433,8 +433,12 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + // LLPanelRegionInfo + /*virtual*/ bool refreshFromRegion(LLViewerRegion* region); + private: void refresh(); + void setControlsEnabled(bool enabled); void populateWaterPresetsList(); void populateSkyPresetsList(); @@ -446,6 +450,10 @@ private: void onBtnSave(); void onBtnCancel(); + void onRegionSettingschange(); + + bool mEnableEditing; + LLRadioGroup* mRegionSettingsRadioGroup; LLRadioGroup* mDayCycleSettingsRadioGroup; -- cgit v1.2.3 From 047f69bf618fa525410dc512977e384cbbdb4d11 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 24 May 2011 19:05:41 +0300 Subject: STORM-1256 WIP Fixed resetting the Environment tab if a server env. update comes while your preference is using personal env. settings. The fix is to re-add server skies to our WL param mgr regardless of user preferences. --- indra/newview/llenvmanager.cpp | 6 ++---- indra/newview/llwlparammanager.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 688e2ea9bf..85a7c4d069 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -820,10 +820,8 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) mCachedRegionPrefs = new_settings; // If using server settings, update managers. - if (getUseRegionSettings()) - { - updateManagersFromPrefs(mInterpNextChangeMessage); - } + // This also adds server skies to the WL param mgr. + updateManagersFromPrefs(mInterpNextChangeMessage); // Let interested parties know about the region settings update. mRegionSettingsChangeSignal(); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 16abe2b174..ec7889cb93 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -589,10 +589,12 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) // Remove all region sky presets because they may belong to a previously visited region. clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + // Add all sky presets belonging to the current region. + const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); + addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); + if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings { - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getSkyMap().size() == 0) { applyDefaults(); @@ -602,9 +604,6 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) // *TODO: Support fixed sky from region. LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - // Add all sky presets belonging to the current region. - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); - // Apply region day cycle. mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); resetAnimator(region_settings.getDayTime(), true); -- cgit v1.2.3 From 406195e4f20e0bea341c8a7a979b56a8259b8536 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 24 May 2011 09:38:49 -0700 Subject: Added badges version 0.1 to buttons. Reviewed by Richard --- indra/llcommon/lldate.h | 2 + indra/llui/CMakeLists.txt | 2 + indra/llui/llbadge.cpp | 263 +++++++++++++++++++++ indra/llui/llbadge.h | 152 ++++++++++++ indra/llui/llbutton.cpp | 94 +++++++- indra/llui/llbutton.h | 12 +- indra/llxuixml/llinitparam.h | 2 + indra/newview/skins/default/colors.xml | 6 + indra/newview/skins/default/textures/textures.xml | 2 + .../skins/default/textures/widgets/Badge.png | Bin 0 -> 1716 bytes .../newview/skins/default/xui/en/widgets/badge.xml | 14 ++ 11 files changed, 543 insertions(+), 6 deletions(-) create mode 100644 indra/llui/llbadge.cpp create mode 100644 indra/llui/llbadge.h create mode 100644 indra/newview/skins/default/textures/widgets/Badge.png create mode 100644 indra/newview/skins/default/xui/en/widgets/badge.xml (limited to 'indra') diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 7ff8b550ad..f2bf2366ac 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -34,6 +34,8 @@ #include "stdtypes.h" +#include "llpreprocessor.h" + /** * @class LLDate * @brief This class represents a particular point in time in UTC. diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 33ab2e93b5..fb585e062c 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -28,6 +28,7 @@ include_directories( set(llui_SOURCE_FILES llaccordionctrl.cpp llaccordionctrltab.cpp + llbadge.cpp llbutton.cpp llcheckboxctrl.cpp llclipboard.cpp @@ -119,6 +120,7 @@ set(llui_HEADER_FILES llaccordionctrl.h llaccordionctrltab.h + llbadge.h llbutton.h llcallbackmap.h llcheckboxctrl.h diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp new file mode 100644 index 0000000000..ea934aa93b --- /dev/null +++ b/indra/llui/llbadge.cpp @@ -0,0 +1,263 @@ +/** + * @file llbadge.cpp + * @brief Implementation for badges + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#define LLBADGE_CPP +#include "llbadge.h" + +#include "lluictrlfactory.h" + + +static LLDefaultChildRegistry::Register r("badge"); + +// Compiler optimization, generate extern template +template class LLBadge* LLView::getChild(const std::string& name, BOOL recurse) const; + + +LLBadge::Params::Params() + : image("image") + , image_color("image_color") + , label("label") + , label_color("label_color") + , location("location", LLRelPos::TOP_LEFT) + , location_percent_hcenter("location_percent_hcenter") + , location_percent_vcenter("location_percent_vcenter") + , padding_horiz("padding_horiz") + , padding_vert("padding_vert") +{ + // We set a name here so the name isn't necessary in any xml files that use badges + name = "badge"; +} + +bool LLBadge::Params::equals(const Params& a) const +{ + bool comp = true; + + // skip owner in comparison on purpose + + comp &= (image() == a.image()); + comp &= (image_color() == a.image_color()); + comp &= (label() == a.label()); + comp &= (label_color() == a.label_color()); + comp &= (location() == a.location()); + comp &= (location_percent_hcenter() == a.location_percent_hcenter()); + comp &= (location_percent_vcenter() == a.location_percent_vcenter()); + comp &= (padding_horiz() == a.padding_horiz()); + comp &= (padding_vert() == a.padding_vert()); + + return comp; +} + +LLBadge::LLBadge(const LLBadge::Params& p) + : LLUICtrl(p) + , mOwner(p.owner) + , mGLFont(p.font) + , mImage(p.image) + , mImageColor(p.image_color) + , mLabel(p.label) + , mLabelColor(p.label_color) + , mLocation(p.location) + , mLocationPercentHCenter(0.5f) + , mLocationPercentVCenter(0.5f) + , mPaddingHoriz(p.padding_horiz) + , mPaddingVert(p.padding_vert) +{ + if (mImage.isNull()) + { + llwarns << "Badge: " << getName() << " with no image!" << llendl; + } + + // + // The following logic is to set the mLocationPercentHCenter and mLocationPercentVCenter + // based on the Location enum and our horizontal and vertical location percentages. The + // draw code then uses this on the owner rectangle to compute the screen location for + // the badge. + // + + if (!LLRelPos::IsCenter(mLocation)) + { + F32 h_center = p.location_percent_hcenter * 0.01f; + F32 v_center = p.location_percent_vcenter * 0.01f; + + if (LLRelPos::IsRight(mLocation)) + { + mLocationPercentHCenter = 0.5f * (1.0f + h_center); + } + else if (LLRelPos::IsLeft(mLocation)) + { + mLocationPercentHCenter = 0.5f * (1.0f - h_center); + } + + if (LLRelPos::IsTop(mLocation)) + { + mLocationPercentVCenter = 0.5f * (1.0f + v_center); + } + else if (LLRelPos::IsBottom(mLocation)) + { + mLocationPercentVCenter = 0.5f * (1.0f - v_center); + } + } +} + +LLBadge::~LLBadge() +{ +} + +void LLBadge::setLabel(const LLStringExplicit& label) +{ + mLabel = label; +} + +// +// This is a fallback function to render a rectangle for badges without a valid image +// +void renderBadgeBackground(F32 centerX, F32 centerY, F32 width, F32 height, const LLColor4U &color) +{ + gGL.pushUIMatrix(); + gGL.loadUIIdentity(); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + gGL.color4ubv(color.mV); + gGL.texCoord2i(0, 0); + + F32 x = LLFontGL::sCurOrigin.mX + centerX - width * 0.5f; + F32 y = LLFontGL::sCurOrigin.mY + centerY - height * 0.5f; + + LLRectf screen_rect(llround(x), + llround(y), + llround(x) + width, + llround(y) + height); + + LLVector3 vertices[4]; + vertices[0] = LLVector3(screen_rect.mRight, screen_rect.mTop, 1.0f); + vertices[1] = LLVector3(screen_rect.mLeft, screen_rect.mTop, 1.0f); + vertices[2] = LLVector3(screen_rect.mLeft, screen_rect.mBottom, 1.0f); + vertices[3] = LLVector3(screen_rect.mRight, screen_rect.mBottom, 1.0f); + + gGL.begin(LLRender::QUADS); + { + gGL.vertexBatchPreTransformed(vertices, 4); + } + gGL.end(); + + gGL.popUIMatrix(); +} + + +// virtual +void LLBadge::draw() +{ + if (!mLabel.empty()) + { + LLUICtrl* owner_ctrl = mOwner.get(); + + if (owner_ctrl) + { + // + // Calculate badge position based on owner + // + + LLRect owner_rect; + owner_ctrl->localRectToOtherView(owner_ctrl->getLocalRect(), & owner_rect, this); + + F32 badge_center_x = owner_rect.mLeft + owner_rect.getWidth() * mLocationPercentHCenter; + F32 badge_center_y = owner_rect.mBottom + owner_rect.getHeight() * mLocationPercentVCenter; + + // + // Calculate badge size based on label text + // + + LLWString badge_label_wstring = mLabel; + + S32 badge_label_begin_offset = 0; + S32 badge_char_length = S32_MAX; + S32 badge_pixel_length = S32_MAX; + F32 *right_position_out = NULL; + BOOL do_not_use_ellipses = false; + + F32 badge_width = (2.0f * mPaddingHoriz) + + mGLFont->getWidthF32(badge_label_wstring.c_str(), badge_label_begin_offset, badge_char_length); + + F32 badge_height = (2.0f * mPaddingVert) + mGLFont->getLineHeight(); + + // + // Draw button image, if available. + // Otherwise draw basic rectangular button. + // + + F32 alpha = getDrawContext().mAlpha; + + if (!mImage.isNull()) + { + F32 badge_x = badge_center_x - badge_width * 0.5f; + F32 badge_y = badge_center_y - badge_height * 0.5f; + + mImage->drawSolid(badge_x, badge_y, badge_width, badge_height, mImageColor % alpha); + } + else + { + lldebugs << "No image for badge " << getName() << " on owner " << owner_ctrl->getName() << llendl; + + renderBadgeBackground(badge_center_x, badge_center_y, + badge_width, badge_height, + mImageColor % alpha); + } + + // + // Draw the label + // + + mGLFont->render(badge_label_wstring, badge_label_begin_offset, + badge_center_x, badge_center_y, + mLabelColor % alpha, + LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position + LLFontGL::NORMAL, // normal text (not bold, italics, etc.) + LLFontGL::DROP_SHADOW_SOFT, + badge_char_length, badge_pixel_length, + right_position_out, do_not_use_ellipses); + } + } +} + + +namespace LLInitParam +{ + void TypeValues::declareValues() + { + declare("bottom", LLRelPos::BOTTOM); + declare("bottom_left", LLRelPos::BOTTOM_LEFT); + declare("bottom_right", LLRelPos::BOTTOM_RIGHT); + declare("center", LLRelPos::CENTER); + declare("left", LLRelPos::LEFT); + declare("right", LLRelPos::RIGHT); + declare("top", LLRelPos::TOP); + declare("top_left", LLRelPos::TOP_LEFT); + declare("top_right", LLRelPos::TOP_RIGHT); + } +} + + +// eof diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h new file mode 100644 index 0000000000..c2e0a763b2 --- /dev/null +++ b/indra/llui/llbadge.h @@ -0,0 +1,152 @@ +/** + * @file llbadge.h + * @brief Header for badges + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLBADGE_H +#define LL_LLBADGE_H + +#include + +#include "lluicolor.h" +#include "lluictrl.h" +#include "llstring.h" +#include "lluiimage.h" + +// +// Declarations +// + +class LLUICtrlFactory; +class LLFontGL; + +// +// Relative Position Alignment +// + +namespace LLRelPos +{ + enum Location + { + CENTER = 0, + + LEFT = (1 << 0), + RIGHT = (1 << 1), + + TOP = (1 << 2), + BOTTOM = (1 << 3), + + BOTTOM_LEFT = (BOTTOM | LEFT), + BOTTOM_RIGHT = (BOTTOM | RIGHT), + + TOP_LEFT = (TOP | LEFT), + TOP_RIGHT = (TOP | RIGHT), + }; + + inline bool IsBottom(Location relPos) { return (relPos & BOTTOM) == BOTTOM; } + inline bool IsCenter(Location relPos) { return (relPos == CENTER); } + inline bool IsLeft(Location relPos) { return (relPos & LEFT) == LEFT; } + inline bool IsRight(Location relPos) { return (relPos & RIGHT) == RIGHT; } + inline bool IsTop(Location relPos) { return (relPos & TOP) == TOP; } +} + +// NOTE: This needs to occur before Optional declaration for proper compilation. +namespace LLInitParam +{ + template<> + struct TypeValues : public TypeValuesHelper + { + static void declareValues(); + }; +} + +// +// Classes +// + +class LLBadge +: public LLUICtrl +{ +public: + struct Params + : public LLInitParam::Block + { + Optional< LLHandle > owner; // Mandatory in code but not in xml + + Optional< LLUIImage* > image; + Optional< LLUIColor > image_color; + + Optional< std::string > label; + Optional< LLUIColor > label_color; + + Optional< LLRelPos::Location > location; + Optional< U32 > location_percent_hcenter; + Optional< U32 > location_percent_vcenter; + + Optional< F32 > padding_horiz; + Optional< F32 > padding_vert; + + Params(); + + bool equals(const Params&) const; + }; + +protected: + friend class LLUICtrlFactory; + LLBadge(const Params& p); + +public: + + ~LLBadge(); + + virtual void draw(); + + const std::string getLabel() const { return wstring_to_utf8str(mLabel); } + void setLabel( const LLStringExplicit& label); + +private: + const LLFontGL* mGLFont; + + LLPointer< LLUIImage > mImage; + LLUIColor mImageColor; + + LLUIString mLabel; + LLUIColor mLabelColor; + + LLRelPos::Location mLocation; + F32 mLocationPercentHCenter; + F32 mLocationPercentVCenter; + + LLHandle< LLUICtrl > mOwner; + + F32 mPaddingHoriz; + F32 mPaddingVert; +}; + +// Build time optimization, generate once in .cpp file +#ifndef LLBADGE_CPP +extern template class LLBadge* LLView::getChild(const std::string& name, BOOL recurse) const; +#endif + +#endif // LL_LLBADGE_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 45ceaff696..a63281b3c1 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -56,6 +56,9 @@ static LLDefaultChildRegistry::Register r("button"); template class LLButton* LLView::getChild( const std::string& name, BOOL recurse) const; + + + // globals loaded from settings.xml S32 LLBUTTON_H_PAD = 0; S32 BTN_HEIGHT_SMALL= 0; @@ -99,7 +102,8 @@ LLButton::Params::Params() scale_image("scale_image", true), hover_glow_amount("hover_glow_amount"), commit_on_return("commit_on_return", true), - use_draw_context_alpha("use_draw_context_alpha", true) + use_draw_context_alpha("use_draw_context_alpha", true), + badge("badge") { addSynonym(is_toggle, "toggle"); held_down_delay.seconds = 0.5f; @@ -160,8 +164,8 @@ LLButton::LLButton(const LLButton::Params& p) mMouseDownSignal(NULL), mMouseUpSignal(NULL), mHeldDownSignal(NULL), - mUseDrawContextAlpha(p.use_draw_context_alpha) - + mUseDrawContextAlpha(p.use_draw_context_alpha), + mBadge(NULL) { static LLUICachedControl llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams()); @@ -244,6 +248,17 @@ LLButton::LLButton(const LLButton::Params& p) { setHeldDownCallback(initCommitCallback(p.mouse_held_callback)); } + + // Only create a badge here if a non-default one was provided. + if (p.badge.isProvided()) + { + if (!p.badge().equals(LLUICtrlFactory::getDefaultParams())) + { + LLBadge::Params badge_params(p.badge()); + badge_params.owner = getUICtrlHandle(); + mBadge = LLUICtrlFactory::create(badge_params); + } + } } LLButton::~LLButton() @@ -327,6 +342,13 @@ boost::signals2::connection LLButton::setHeldDownCallback( button_callback_t cb, BOOL LLButton::postBuild() { autoResize(); + + // Attach the badge to the appropriate parent panel + if (mBadge) + { + addBadgeToParentPanel(); + } + return TRUE; } BOOL LLButton::handleUnicodeCharHere(llwchar uni_char) @@ -867,7 +889,7 @@ void LLButton::draw() S32_MAX, text_width, NULL, mUseEllipses); } - + LLUICtrl::draw(); } @@ -1063,6 +1085,70 @@ void LLButton::setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignmen } } +void LLButton::addBadgeToParentPanel() +{ + if (mBadge) + { + // Find the appropriate parent panel for the badge + + LLPanel * parentPanel = NULL; + LLUICtrl * parent = getParentUICtrl(); + + while (parent) + { + parentPanel = dynamic_cast(parent); + + if (parentPanel != NULL) + { + break; + } + + parent = parent->getParentUICtrl(); + } + + if (parentPanel) + { + parentPanel->addChild(mBadge); + } + else + { + llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on button " << getName() << llendl; + } + } + else + { + llwarns << "Unable to add NULL badge to button " << getName() << llendl; + } +} + +void LLButton::setBadgeLabel(const LLStringExplicit& label) +{ + if (mBadge == NULL) + { + LLBadge::Params badge_params(LLUICtrlFactory::getDefaultParams()); + badge_params.owner = getUICtrlHandle(); + mBadge = LLUICtrlFactory::create(badge_params); + + addBadgeToParentPanel(); + } + + if (mBadge) + { + mBadge->setLabel(label); + + // + // Push the badge to the front so it renders last + // + + LLUICtrl * parent = mBadge->getParentUICtrl(); + + if (parent) + { + parent->sendChildToFront(mBadge); + } + } +} + void LLButton::onMouseCaptureLost() { resetMouseDownTimer(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 0cfc393e05..232ab81e0d 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -27,6 +27,8 @@ #ifndef LL_LLBUTTON_H #define LL_LLBUTTON_H +#include "lluuid.h" +#include "llbadge.h" #include "llcontrol.h" #include "lluictrl.h" #include "v4color.h" @@ -52,8 +54,6 @@ S32 round_up(S32 grid, S32 value); class LLUICtrlFactory; -class LLUIImage; -class LLUUID; // // Classes @@ -126,6 +126,8 @@ public: Optional held_down_delay; Optional use_draw_context_alpha; + + Optional badge; Params(); }; @@ -249,6 +251,8 @@ public: void setImageDisabledSelected(LLPointer image); void setImageFlash(LLPointer image); void setImagePressed(LLPointer image); + + void setBadgeLabel(const LLStringExplicit& label); void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } BOOL getCommitOnReturn() const { return mCommitOnReturn; } @@ -267,6 +271,8 @@ protected: LLPointer getImageUnselected() const { return mImageUnselected; } LLPointer getImageSelected() const { return mImageSelected; } + void addBadgeToParentPanel(); + LLFrameTimer mMouseDownTimer; private: @@ -357,6 +363,8 @@ private: bool mForcePressedState; LLFrameTimer mFlashingTimer; + + LLBadge* mBadge; }; // Build time optimization, generate once in .cpp file diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index a853999e94..ce7cb5b3e0 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -34,6 +34,8 @@ #include #include +#include "llerror.h" + namespace LLInitParam { template const T& defaultValue() { static T value; return value; } diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index a19eccf748..0795e38366 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -132,6 +132,12 @@ + + diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 4f19dd9a6d..2a78337f65 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -72,6 +72,8 @@ with the same filename but different name + + diff --git a/indra/newview/skins/default/textures/widgets/Badge.png b/indra/newview/skins/default/textures/widgets/Badge.png new file mode 100644 index 0000000000..afda6b66b9 Binary files /dev/null and b/indra/newview/skins/default/textures/widgets/Badge.png differ diff --git a/indra/newview/skins/default/xui/en/widgets/badge.xml b/indra/newview/skins/default/xui/en/widgets/badge.xml new file mode 100644 index 0000000000..4eb633ac0c --- /dev/null +++ b/indra/newview/skins/default/xui/en/widgets/badge.xml @@ -0,0 +1,14 @@ + + + + -- cgit v1.2.3 From d755605f8dc5bba0abdb87f075db2b6a5ed4ecad Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 24 May 2011 20:21:23 +0300 Subject: STORM-1256 WIP Added perpetual indicator for progress of applying changes. --- indra/newview/llenvmanager.cpp | 11 +++++++ indra/newview/llenvmanager.h | 6 ++++ indra/newview/llfloaterregioninfo.cpp | 35 ++++++++++++++++++++++ indra/newview/llfloaterregioninfo.h | 2 ++ indra/newview/llwlhandlers.cpp | 2 ++ .../default/xui/en/panel_region_environment.xml | 7 +++++ 6 files changed, 63 insertions(+) (limited to 'indra') diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 85a7c4d069..a08ca88459 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -796,6 +796,11 @@ boost::signals2::connection LLEnvManagerNew::setRegionChangeCallback(const regio return mRegionChangeSignal.connect(cb); } +boost::signals2::connection LLEnvManagerNew::setRegionSettingsAppliedCallback(const region_settings_applied_signal_t::slot_type& cb) +{ + return mRegionSettingsAppliedSignal.connect(cb); +} + void LLEnvManagerNew::onRegionCrossing() { LL_DEBUGS("Windlight") << "Crossed region" << LL_ENDL; @@ -830,6 +835,12 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) mInterpNextChangeMessage = false; } +void LLEnvManagerNew::onRegionSettingsApplyResponse(bool ok) +{ + LL_DEBUGS("Windlight") << "Applying region settings " << (ok ? "succeeded" : "failed") << LL_ENDL; + mRegionSettingsAppliedSignal(ok); +} + //-- private methods ---------------------------------------------------------- // virtual diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index eb678e000e..52b645b535 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -261,6 +261,7 @@ class LLEnvManagerNew : public LLSingleton public: typedef boost::signals2::signal region_settings_change_signal_t; typedef boost::signals2::signal region_change_signal_t; + typedef boost::signals2::signal region_settings_applied_signal_t; LLEnvManagerNew(); @@ -300,11 +301,13 @@ public: bool sendRegionSettings(const LLEnvironmentSettings& new_settings); boost::signals2::connection setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb); boost::signals2::connection setRegionChangeCallback(const region_change_signal_t::slot_type& cb); + boost::signals2::connection setRegionSettingsAppliedCallback(const region_settings_applied_signal_t::slot_type& cb); // Public callbacks. void onRegionCrossing(); void onTeleport(); void onRegionSettingsResponse(const LLSD& content); + void onRegionSettingsApplyResponse(bool ok); private: friend class LLSingleton; @@ -320,6 +323,9 @@ private: /// Emitted when agent region changes. Move to LLAgent? region_settings_change_signal_t mRegionChangeSignal; + /// Emitted when agent region changes. Move to LLAgent? + region_settings_applied_signal_t mRegionSettingsAppliedSignal; + LLEnvPrefs mUserPrefs; /// User environment preferences. LLEnvironmentSettings mCachedRegionPrefs; /// Cached region environment settings. bool mInterpNextChangeMessage; /// Interpolate env. settings on next region change. diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 657dd67035..d47fb00060 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -40,6 +40,7 @@ #include "llxfermanager.h" #include "indra_constants.h" #include "message.h" +#include "llloadingindicator.h" #include "llradiogroup.h" #include "llsd.h" #include "llsdserialize.h" @@ -3203,6 +3204,7 @@ BOOL LLPanelEnvironmentInfo::postBuild() childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); + LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); return TRUE; } @@ -3265,6 +3267,22 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) } } +void LLPanelEnvironmentInfo::setApplyProgress(bool started) +{ + LLLoadingIndicator* indicator = getChild("progress_indicator"); + + indicator->setVisible(started); + + if (started) + { + indicator->start(); + } + else + { + indicator->stop(); + } +} + void LLPanelEnvironmentInfo::populateWaterPresetsList() { mWaterPresetCombo->removeall(); @@ -3457,7 +3475,10 @@ void LLPanelEnvironmentInfo::onBtnSave() if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) { llwarns << "Error applying region environment settings" << llendl; + return; } + + setApplyProgress(true); } void LLPanelEnvironmentInfo::onBtnCancel() @@ -3470,4 +3491,18 @@ void LLPanelEnvironmentInfo::onRegionSettingschange() { LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; refresh(); + + // Stop applying progress indicator (it may be running if it's us who initiated settings update). + setApplyProgress(false); +} + +void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) +{ + LL_DEBUGS("Windlight") << "Applying region settings finished, stopping indicator" << LL_ENDL; + // If applying new settings has failed, stop the indicator right away. + // Otherwise it will be stopped when we receive the updated settings from server. + if (!ok) + { + setApplyProgress(false); + } } diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 4dc235ad19..d96ab1339f 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -439,6 +439,7 @@ public: private: void refresh(); void setControlsEnabled(bool enabled); + void setApplyProgress(bool started); void populateWaterPresetsList(); void populateSkyPresetsList(); @@ -451,6 +452,7 @@ private: void onBtnCancel(); void onRegionSettingschange(); + void onRegionSettingsApplied(bool ok); bool mEnableEditing; diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 32ef4ac6ad..b5f53232cc 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -179,6 +179,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) else if (content["success"].asBoolean()) { LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << content["regionID"].asUUID() << LL_ENDL; + LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); } else { @@ -186,6 +187,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) LLSD args(LLSD::emptyMap()); args["FAIL_REASON"] = content["fail_reason"].asString(); LLNotificationsUtil::add("WLRegionApplyFail", args); + LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); } } /*virtual*/ void LLEnvironmentApplyResponder::error(U32 status, const std::string& reason) diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml index 907a707db8..956ba53a26 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -137,4 +137,11 @@ left_pad="10" name="cancel_btn" width="100" /> + -- cgit v1.2.3 From 72d1efb1529ad0863d35b219a461f353a4b19353 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 24 May 2011 20:29:46 +0300 Subject: STORM-1256 WIP Re-request region settings if our attempt to change them has failed. --- indra/newview/llfloaterregioninfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra') diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index d47fb00060..ff34e21c2f 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3504,5 +3504,12 @@ void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) if (!ok) { setApplyProgress(false); + + // We need to re-request environment setting here, + // otherwise our subsequent attempts to change region settings will fail with the following error: + // "Unable to update environment settings because the last update your viewer saw was not the same + // as the last update sent from the simulator. Try sending your update again, and if this + // does not work, try leaving and returning to the region." + LLEnvManagerNew::instance().requestRegionSettings(); } } -- cgit v1.2.3 From 1a5b3b0a9091a72fd5e5fb395f7f0c97b0fd502c Mon Sep 17 00:00:00 2001 From: Dave SIMmONs Date: Tue, 24 May 2011 10:44:27 -0700 Subject: ER-914: Disable Parcel Privacy UI in viewer if on older sim --- indra/llinventory/llparcel.cpp | 4 ++++ indra/llinventory/llparcel.h | 4 +++- indra/newview/llfloaterland.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 7562bb8320..6236c0df6b 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -226,6 +226,9 @@ void LLParcel::init(const LLUUID &owner_id, setPreviousOwnerID(LLUUID::null); setPreviouslyGroupOwned(FALSE); + + setPrivacy(false); + setHavePrivacyData(false); } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) @@ -728,6 +731,7 @@ void LLParcel::unpackMessage(LLMessageSystem* msg) msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_Privacy, private_parcel); } setPrivacy((bool) private_parcel); + setHavePrivacyData(have_privacy_data); // non-optimized version msg->getU8 ( "ParcelData", "MediaAutoScale", mMediaAutoScale ); diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 4d2236ec66..1b2f372888 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -272,6 +272,7 @@ public: void setUserLookAt(const LLVector3& rot) { mUserLookAt = rot; } void setLandingType(const ELandingType type) { mLandingType = type; } void setPrivacy(bool privacy) { mPrivacy = privacy; } + void setHavePrivacyData(bool have_privacy_data) { mHavePrivacyData = have_privacy_data; } // Remove this once parcel privacy is fully available grid-wide void setAuctionID(U32 auction_id) { mAuctionID = auction_id;} @@ -375,7 +376,7 @@ public: const LLVector3& getUserLookAt() const { return mUserLookAt; } ELandingType getLandingType() const { return mLandingType; } bool getPrivacy() const { return mPrivacy; } - + bool getHavePrivacyData() const { return mHavePrivacyData; } // User-specified snapshot const LLUUID& getSnapshotID() const { return mSnapshotID; } @@ -612,6 +613,7 @@ protected: LLVector3 mUserLookAt; ELandingType mLandingType; bool mPrivacy; + bool mHavePrivacyData; // Remove once parcel privacy is grid-wide LLTimer mSaleTimerExpires; LLTimer mMediaResetTimer; diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index d9d2c3d5a6..8de93a385f 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -2036,7 +2036,7 @@ void LLPanelLandOptions::refresh() mPrivateParcelCtrl->set(parcel->getPrivacy()); mPrivateParcelCtrl->setLabel(getString("private_parcel_text")); - mPrivateParcelCtrl->setEnabled(can_change_options); + mPrivateParcelCtrl->setEnabled(can_change_options && parcel->getHavePrivacyData()); BOOL can_change_landing_point = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_SET_LANDING_POINT); -- cgit v1.2.3 From 5fc0cd9bf7d0c7f97bb63c5f887cce27e27a05f9 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 25 May 2011 08:55:03 -0400 Subject: storm-1156: remove "test day" controls and associated code --- indra/newview/llfloaterdaycycle.cpp | 134 --------------------- indra/newview/llfloaterdaycycle.h | 18 --- .../default/xui/en/floater_day_cycle_options.xml | 119 ------------------ 3 files changed, 271 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index eb429d7803..ebf7b98148 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -114,47 +114,16 @@ void LLFloaterDayCycle::initCallbacks(void) childSetCommitCallback("WLCurKeyMin", onKeyTimeChanged, NULL); childSetCommitCallback("WLKeyPresets", onKeyPresetChanged, NULL); - childSetCommitCallback("WLLengthOfDayHour", onTimeRateChanged, NULL); - childSetCommitCallback("WLLengthOfDayMin", onTimeRateChanged, NULL); - childSetCommitCallback("WLLengthOfDaySec", onTimeRateChanged, NULL); - childSetAction("WLUseLindenTime", onUseLindenTime, NULL); - childSetAction("WLAnimSky", onRunAnimSky, NULL); - childSetAction("WLStopAnimSky", onStopAnimSky, NULL); - - childSetAction("WLLoadDayCycle", onLoadDayCycle, NULL); - childSetAction("WLSaveDayCycle", onSaveDayCycle, NULL); - childSetAction("WLAddKey", onAddKey, NULL); childSetAction("WLDeleteKey", onDeleteKey, NULL); } void LLFloaterDayCycle::syncMenu() { -// std::map & currentParams = LLWLParamManager::getInstance()->mCurParams.mParamValues; - // set time LLMultiSliderCtrl* sldr = LLFloaterDayCycle::sDayCycle->getChild("WLTimeSlider"); sldr->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); - LLSpinCtrl* secSpin = sDayCycle->getChild("WLLengthOfDaySec"); - LLSpinCtrl* minSpin = sDayCycle->getChild("WLLengthOfDayMin"); - LLSpinCtrl* hourSpin = sDayCycle->getChild("WLLengthOfDayHour"); - - F32 curRate; - F32 hours, min, sec; - - // get the current rate - curRate = LLWLParamManager::getInstance()->mDay.mDayRate; - hours = (F32)((int)(curRate / 60 / 60)); - curRate -= (hours * 60 * 60); - min = (F32)((int)(curRate / 60)); - curRate -= (min * 60); - sec = curRate; - - hourSpin->setValue(hours); - minSpin->setValue(min); - secSpin->setValue(sec); - // turn off Use Estate Time button if it's already being used if( LLWLParamManager::getInstance()->mAnimator.getUseLindenTime()) { @@ -309,81 +278,6 @@ void LLFloaterDayCycle::onClose(bool app_quitting) } } -void LLFloaterDayCycle::onRunAnimSky(void* userData) -{ - // if no keys, do nothing - if(sSliderToKey.size() == 0) - { - return; - } - - LLMultiSliderCtrl* sldr; - sldr = sDayCycle->getChild("WLDayCycleKeys"); - llassert_always(sSliderToKey.size() == sldr->getValue().size()); - - LLMultiSliderCtrl* tSldr = sDayCycle->getChild("WLTimeSlider"); - - sPreviousTimeType = LLWLParamManager::getInstance()->mAnimator.getTimeType(); - - // turn off linden time - LLWLParamManager::getInstance()->mAnimator.setTimeType(LLWLAnimator::TIME_CUSTOM); - - // set the param manager's track to the new one - LLWLParamManager::getInstance()->resetAnimator(tSldr->getCurSliderValue() / sHoursPerDay, true); - - llassert_always(LLWLParamManager::getInstance()->mAnimator.mTimeTrack.size() == sldr->getValue().size()); -} - -void LLFloaterDayCycle::onStopAnimSky(void* userData) -{ - // if no keys, do nothing - if(sSliderToKey.size() == 0) { - return; - } - - LLWLParamManager::getInstance()->mAnimator.deactivate(); // turn off animation and using linden time - LLMultiSliderCtrl* tSldr = sDayCycle->getChild("WLTimeSlider"); - LLWLParamManager::getInstance()->resetAnimator(tSldr->getCurSliderValue() / sHoursPerDay, false); - LLWLParamManager::getInstance()->mAnimator.setTimeType(sPreviousTimeType); -} - -void LLFloaterDayCycle::onUseLindenTime(void* userData) -{ - LLFloaterWindLight* wlfloater = LLFloaterReg::findTypedInstance("env_windlight"); - if (wlfloater) - { - LLComboBox* box = wlfloater->getChild("WLPresetsCombo"); - box->selectByValue(""); - } - LLWLParamManager::getInstance()->mAnimator.deactivate(); -} - -void LLFloaterDayCycle::onLoadDayCycle(void* userData) -{ - LLWLParamManager::getInstance()->mDay.loadDayCycleFromFile("Default.xml"); - - // sync it all up - syncSliderTrack(); - syncMenu(); - - // set the param manager's track to the new one - LLMultiSliderCtrl* tSldr; - tSldr = sDayCycle->getChild( - "WLTimeSlider"); - LLWLParamManager::getInstance()->resetAnimator( - tSldr->getCurSliderValue() / sHoursPerDay, false); - - // and draw it - LLWLParamManager::getInstance()->mAnimator.update( - LLWLParamManager::getInstance()->mCurParams); -} - -void LLFloaterDayCycle::onSaveDayCycle(void* userData) -{ - LLWLParamManager::getInstance()->mDay.saveDayCycle("Default.xml"); -} - - void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl, void* userData) { LLMultiSliderCtrl* sldr = sDayCycle->getChild( @@ -501,34 +395,6 @@ void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl, void* userData) syncTrack(); } -void LLFloaterDayCycle::onTimeRateChanged(LLUICtrl* ctrl, void* userData) -{ - // get the time - LLSpinCtrl* secSpin = sDayCycle->getChild( - "WLLengthOfDaySec"); - - LLSpinCtrl* minSpin = sDayCycle->getChild( - "WLLengthOfDayMin"); - - LLSpinCtrl* hourSpin = sDayCycle->getChild( - "WLLengthOfDayHour"); - - F32 hour; - hour = (F32)hourSpin->getValue().asReal(); - F32 min; - min = (F32)minSpin->getValue().asReal(); - F32 sec; - sec = (F32)secSpin->getValue().asReal(); - - F32 time = 60.0f * 60.0f * hour + 60.0f * min + sec; - if(time <= 0) { - time = 1; - } - LLWLParamManager::getInstance()->mDay.mDayRate = time; - - syncTrack(); -} - void LLFloaterDayCycle::onAddKey(void* userData) { LLComboBox* comboBox = sDayCycle->getChild( diff --git a/indra/newview/llfloaterdaycycle.h b/indra/newview/llfloaterdaycycle.h index b09d1d5bf4..1454298269 100644 --- a/indra/newview/llfloaterdaycycle.h +++ b/indra/newview/llfloaterdaycycle.h @@ -83,15 +83,6 @@ public: /// if you change the combo box, change the frame static void onKeyPresetChanged(LLUICtrl* ctrl, void* userData); - /// run this when user says to run the sky animation - static void onRunAnimSky(void* userData); - - /// run this when user says to stop the sky animation - static void onStopAnimSky(void* userData); - - /// if you change the combo box, change the frame - static void onTimeRateChanged(LLUICtrl* ctrl, void* userData); - /// add a new key on slider static void onAddKey(void* userData); @@ -101,15 +92,6 @@ public: /// delete a key frame static void onDeleteKey(void* userData); - /// button to load day - static void onLoadDayCycle(void* userData); - - /// button to save day - static void onSaveDayCycle(void* userData); - - /// toggle for Linden time - static void onUseLindenTime(void* userData); - //// menu management diff --git a/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml b/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml index b54dc87d24..59cdb295ef 100644 --- a/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml +++ b/indra/newview/skins/default/xui/en/floater_day_cycle_options.xml @@ -411,125 +411,6 @@ left="12" top="101" width="240" /> - - Length of Cycle: - - - - - - Preview : - - - - Just a panel - - - - - - - - + + + + + + + - Just a panel + -- cgit v1.2.3 From fb9ef6233125d55d47104333d6b0062509850ff4 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 26 May 2011 06:31:11 -0400 Subject: storm-1189: remove classic clouds --- indra/newview/CMakeLists.txt | 2 - indra/newview/app_settings/settings.xml | 11 ------ indra/newview/featuretable.txt | 2 - indra/newview/featuretable_linux.txt | 2 - indra/newview/featuretable_mac.txt | 2 - indra/newview/featuretable_xp.txt | 2 - indra/newview/llappviewer.cpp | 6 +-- indra/newview/llfloaterwindlight.cpp | 6 +-- indra/newview/llviewerregion.cpp | 4 -- indra/newview/llviewerregion.h | 2 - indra/newview/llvlmanager.cpp | 2 +- indra/newview/llworld.cpp | 43 ++++++---------------- .../default/xui/en/floater_edit_sky_preset.xml | 10 ----- .../default/xui/en/floater_windlight_options.xml | 10 ----- 14 files changed, 15 insertions(+), 89 deletions(-) (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5f0a7f5b66..5a9ee92b0c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -119,7 +119,6 @@ set(viewer_SOURCE_FILES llchiclet.cpp llclassifiedinfo.cpp llclassifiedstatsresponder.cpp - llcloud.cpp llcofwearables.cpp llcolorswatch.cpp llcommanddispatcherlistener.cpp @@ -672,7 +671,6 @@ set(viewer_HEADER_FILES llchiclet.h llclassifiedinfo.h llclassifiedstatsresponder.h - llcloud.h llcofwearables.h llcolorswatch.h llcommanddispatcherlistener.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index a3b8ee177a..d1d64516f9 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10187,17 +10187,6 @@ 0.1 - SkyUseClassicClouds - - Comment - Whether to use the old Second Life particle clouds or not - Persist - 1 - Type - Boolean - Value - 1 - SnapEnabled Comment diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index dd8a88e558..9cc6893b15 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -59,7 +59,6 @@ Disregard96DefaultDrawDistance 1 1 RenderTextureMemoryMultiple 1 1.0 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 -SkyUseClassicClouds 1 1 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 WatchdogDisabled 1 1 @@ -91,7 +90,6 @@ RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -SkyUseClassicClouds 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt index 058bdcc730..1aa6314246 100644 --- a/indra/newview/featuretable_linux.txt +++ b/indra/newview/featuretable_linux.txt @@ -57,7 +57,6 @@ WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 RenderTextureMemoryMultiple 1 1.0 -SkyUseClassicClouds 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 @@ -89,7 +88,6 @@ RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -SkyUseClassicClouds 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index c075c660f3..9a8e4d04be 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -58,7 +58,6 @@ Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 RenderTextureMemoryMultiple 1 0.5 RenderShaderLightingMaxLevel 1 3 -SkyUseClassicClouds 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 @@ -91,7 +90,6 @@ RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -SkyUseClassicClouds 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 diff --git a/indra/newview/featuretable_xp.txt b/indra/newview/featuretable_xp.txt index 3339172a1a..9b9e1f6ead 100644 --- a/indra/newview/featuretable_xp.txt +++ b/indra/newview/featuretable_xp.txt @@ -58,7 +58,6 @@ Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 RenderTextureMemoryMultiple 1 1.0 RenderShaderLightingMaxLevel 1 3 -SkyUseClassicClouds 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 @@ -91,7 +90,6 @@ RenderVolumeLODFactor 1 0.5 VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 WLSkyDetail 1 48 -SkyUseClassicClouds 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 84db514ecf..f6fba3cbc4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1,4 +1,4 @@ - /** +/** * @file llappviewer.cpp * @brief The LLAppViewer class definitions * @@ -4311,7 +4311,6 @@ void LLAppViewer::idle() // // Update weather effects // - LLWorld::getInstance()->updateClouds(gFrameDTClamped); gSky.propagateHeavenlyBodies(gFrameDTClamped); // moves sun, moon, and planets // Update wind vector @@ -4327,9 +4326,6 @@ void LLAppViewer::idle() // Compute average wind and use to drive motion of water average_wind = regionp->mWind.getAverage(); - F32 cloud_density = regionp->mCloudLayer.getDensityRegion(wind_position_region); - - gSky.setCloudDensityAtAgent(cloud_density); gSky.setWind(average_wind); //LLVOWater::setWind(average_wind); } diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index b90f576555..fb69e6f594 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -180,8 +180,6 @@ void LLFloaterWindLight::initCallbacks(void) childSetCommitCallback("WLCloudDetailDensity", onColorControlBMoved, ¶m_mgr->mCloudDetail); // Cloud extras - static std::string use_classic_clouds = "SkyUseClassicClouds"; - childSetCommitCallback("WLCloudCoverage", onFloatControlMoved, ¶m_mgr->mCloudCoverage); childSetCommitCallback("WLCloudScale", onFloatControlMoved, ¶m_mgr->mCloudScale); childSetCommitCallback("WLCloudLockX", onCloudScrollXToggled, NULL); @@ -189,8 +187,7 @@ void LLFloaterWindLight::initCallbacks(void) childSetCommitCallback("WLCloudScrollX", onCloudScrollXMoved, NULL); childSetCommitCallback("WLCloudScrollY", onCloudScrollYMoved, NULL); childSetCommitCallback("WLDistanceMult", onFloatControlMoved, ¶m_mgr->mDistanceMult); - getChild("DrawClassicClouds")->setCommitCallback(boost::bind(LLSavedSettingsGlue::setBOOL, _1, "SkyUseClassicClouds")); - + // WL Top childSetAction("WLDayCycleMenuButton", onOpenDayCycle, NULL); // Load/save @@ -373,7 +370,6 @@ void LLFloaterWindLight::syncMenu() bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); childSetValue("WLCloudLockX", lockX); childSetValue("WLCloudLockY", lockY); - childSetValue("DrawClassicClouds", gSavedSettings.getBOOL("SkyUseClassicClouds")); // disable if locked, enable if not if(lockX) diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 9b3ec80c03..214db03994 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -349,7 +349,6 @@ LLViewerRegion::~LLViewerRegion() // Can't do this on destruction, because the neighbor pointers might be invalid. // This should be reference counted... disconnectAllNeighbors(); - mCloudLayer.destroy(); LLViewerPartSim::getInstance()->cleanupRegion(this); gObjectList.killObjects(this); @@ -485,7 +484,6 @@ void LLViewerRegion::setOriginGlobal(const LLVector3d &origin_global) updateRenderMatrix(); mImpl->mLandp->setOriginGlobal(origin_global); mWind.setOriginGlobal(origin_global); - mCloudLayer.setOriginGlobal(origin_global); calculateCenterGlobal(); } @@ -708,14 +706,12 @@ void LLViewerRegion::forceUpdate() void LLViewerRegion::connectNeighbor(LLViewerRegion *neighborp, U32 direction) { mImpl->mLandp->connectNeighbor(neighborp->mImpl->mLandp, direction); - mCloudLayer.connectNeighbor(&(neighborp->mCloudLayer), direction); } void LLViewerRegion::disconnectAllNeighbors() { mImpl->mLandp->disconnectAllNeighbors(); - mCloudLayer.disconnectAllNeighbors(); } LLVLComposition * LLViewerRegion::getComposition() const diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index eae04b2f0c..4bc487e4cb 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -34,7 +34,6 @@ #include "lldarray.h" #include "llwind.h" -#include "llcloud.h" #include "llstat.h" #include "v3dmath.h" #include "llstring.h" @@ -334,7 +333,6 @@ protected: public: LLWind mWind; - LLCloudLayer mCloudLayer; LLViewerParcelOverlay *mParcelOverlay; LLStat mBitStat; diff --git a/indra/newview/llvlmanager.cpp b/indra/newview/llvlmanager.cpp index 25f2687fe2..d8de979f56 100644 --- a/indra/newview/llvlmanager.cpp +++ b/indra/newview/llvlmanager.cpp @@ -94,7 +94,7 @@ void LLVLManager::unpackData(const S32 num_packets) } else if (CLOUD_LAYER_CODE == datap->mType) { - datap->mRegionp->mCloudLayer.decompress(bit_pack, &goph); + } } diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index ec24b02934..596ab5931c 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -61,6 +61,8 @@ #include #include +#define TMP_WL_REMOVE_CLOUDS /* disables code for classic clouds */ + // // Globals // @@ -91,8 +93,11 @@ LLWorld::LLWorld() : mLastPacketsIn(0), mLastPacketsOut(0), mLastPacketsLost(0), - mSpaceTimeUSec(0), - mClassicCloudsEnabled(TRUE) + mSpaceTimeUSec(0) +#ifndef TMP_WL_REMOVE_CLOUDS + , + mClassicCloudsEnabled(FALSE) +#endif { for (S32 i = 0; i < 8; i++) { @@ -183,10 +188,12 @@ LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host) llerrs << "Unable to create new region!" << llendl; } +#ifndef TMP_WL_REMOVE_CLOUDS regionp->mCloudLayer.create(regionp); regionp->mCloudLayer.setWidth((F32)mWidth); regionp->mCloudLayer.setWindPointer(®ionp->mWind); - +#endif // TMP_WL_REMOVE_CLOUDS + mRegionList.push_back(regionp); mActiveRegionList.push_back(regionp); mCulledRegionList.push_back(regionp); @@ -661,6 +668,7 @@ void LLWorld::updateParticles() LLViewerPartSim::getInstance()->updateSimulation(); } +#ifndef TMP_WL_REMOVE_CLOUDS void LLWorld::updateClouds(const F32 dt) { static LLFastTimer::DeclareTimer ftm("World Clouds"); @@ -672,33 +680,6 @@ void LLWorld::updateClouds(const F32 dt) return; } - if ( - mClassicCloudsEnabled != - gSavedSettings.getBOOL("SkyUseClassicClouds") ) - { - // The classic cloud toggle has been flipped - // gotta update all of the cloud layers - mClassicCloudsEnabled = - gSavedSettings.getBOOL("SkyUseClassicClouds"); - - if ( !mClassicCloudsEnabled && mActiveRegionList.size() ) - { - // We've transitioned to having classic clouds disabled - // reset all cloud layers. - for ( - region_list_t::iterator iter = mActiveRegionList.begin(); - iter != mActiveRegionList.end(); - ++iter) - { - LLViewerRegion* regionp = *iter; - regionp->mCloudLayer.reset(); - } - - return; - } - } - else if ( !mClassicCloudsEnabled ) return; - if (mActiveRegionList.size()) { for (region_list_t::iterator iter = mActiveRegionList.begin(); @@ -745,7 +726,7 @@ LLCloudGroup* LLWorld::findCloudGroup(const LLCloudPuff &puff) } return NULL; } - +#endif // TMP_WL_REMOVE_CLOUDS void LLWorld::renderPropertyLines() { diff --git a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml index 9d180a1f50..7ddb7ac1e1 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml @@ -987,16 +987,6 @@ name="WLCloudScrollY" top_pad="6" width="200" /> - diff --git a/indra/newview/skins/default/xui/en/floater_windlight_options.xml b/indra/newview/skins/default/xui/en/floater_windlight_options.xml index 249ad95c41..b121f3daa5 100644 --- a/indra/newview/skins/default/xui/en/floater_windlight_options.xml +++ b/indra/newview/skins/default/xui/en/floater_windlight_options.xml @@ -1273,16 +1273,6 @@ name="WLCloudScrollY" top="85" width="200" /> - -- cgit v1.2.3 From c32b19f31d4d5d0b32fcf64cce1cebd7d79b9b05 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 15:11:01 +0300 Subject: STORM-1253 WIP Implemented switching between multiple day cycles (locally and region-wide). --- indra/newview/CMakeLists.txt | 2 + indra/newview/lldaycyclemanager.cpp | 122 +++++++++++++++++++++++++ indra/newview/lldaycyclemanager.h | 66 +++++++++++++ indra/newview/llenvmanager.cpp | 6 -- indra/newview/llenvmanager.h | 3 - indra/newview/llfloaterenvironmentsettings.cpp | 8 +- indra/newview/llfloaterregioninfo.cpp | 23 +++-- indra/newview/llwldaycycle.cpp | 11 ++- indra/newview/llwldaycycle.h | 3 + indra/newview/llwlparammanager.cpp | 20 +++- indra/newview/llwlparammanager.h | 2 +- 11 files changed, 241 insertions(+), 25 deletions(-) create mode 100644 indra/newview/lldaycyclemanager.cpp create mode 100644 indra/newview/lldaycyclemanager.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 81caf9fbd4..b87f3bf3d4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -123,6 +123,7 @@ set(viewer_SOURCE_FILES llcurrencyuimanager.cpp llcylinder.cpp lldateutil.cpp + lldaycyclemanager.cpp lldebugmessagebox.cpp lldebugview.cpp lldelayedgestureerror.cpp @@ -670,6 +671,7 @@ set(viewer_HEADER_FILES llcurrencyuimanager.h llcylinder.h lldateutil.h + lldaycyclemanager.h lldebugmessagebox.h lldebugview.h lldelayedgestureerror.h diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp new file mode 100644 index 0000000000..c0eae8cd3c --- /dev/null +++ b/indra/newview/lldaycyclemanager.cpp @@ -0,0 +1,122 @@ +/** + * @file lldaycyclemanager.cpp + * @brief Implementation for the LLDayCycleManager class. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lldaycyclemanager.h" + +#include "lldiriterator.h" + +const LLDayCycleManager::dc_map_t& LLDayCycleManager::getPresets() +{ + // Refresh day cycles. + loadAllPresets(); + + return mDayCycleMap; +} + +bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycle) +{ + dc_map_t::const_iterator it = mDayCycleMap.find(name); + if (it == mDayCycleMap.end()) + { + return false; + } + + day_cycle = it->second; + return true; +} + +bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) +{ + LLWLDayCycle dc; + if (!getPreset(name, dc)) + { + return false; + } + + day_cycle = dc.asLLSD(); + return true; +} + +// virtual +void LLDayCycleManager::initSingleton() +{ + LL_DEBUGS("Windlight") << "Loading all day cycles" << LL_ENDL; + loadAllPresets(); +} + +void LLDayCycleManager::loadAllPresets() +{ + mDayCycleMap.clear(); + + // First, load system (coming out of the box) day cycles. + loadPresets(getSysDir()); + + // Then load user presets. Note that user day cycles will modify any system ones already loaded. + loadPresets(getUserDir()); +} + +void LLDayCycleManager::loadPresets(const std::string& dir) +{ + LLDirIterator dir_iter(dir, "*.xml"); + + while (1) + { + std::string file; + if (!dir_iter.next(file)) break; // no more files + loadPreset(dir + file); + } +} + +bool LLDayCycleManager::loadPreset(const std::string& path) +{ + LLSD data = LLWLDayCycle::loadDayCycleFromPath(path); + if (data.isUndefined()) + { + LL_WARNS("Windlight") << "Error loading day cycle from " << path << LL_ENDL; + return false; + } + + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); + LLWLDayCycle day_cycle; + day_cycle.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); + mDayCycleMap[name] = day_cycle; + + return true; +} + +// static +std::string LLDayCycleManager::getSysDir() +{ + return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", ""); +} + +// static +std::string LLDayCycleManager::getUserDir() +{ + return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/days", ""); +} diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h new file mode 100644 index 0000000000..e49e4986fe --- /dev/null +++ b/indra/newview/lldaycyclemanager.h @@ -0,0 +1,66 @@ +/** + * @file lldaycyclemanager.h + * @brief Implementation for the LLDayCycleManager class. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLDAYCYCLEMANAGER_H +#define LL_LLDAYCYCLEMANAGER_H + +#include +#include + +#include "llwldaycycle.h" +#include "llwlparammanager.h" + +/** + * WindLight day cycles manager class + * + * Provides interface for accessing, loading and saving day cycles. + */ +class LLDayCycleManager : public LLSingleton +{ + LOG_CLASS(LLDayCycleManager); + +public: + typedef std::map dc_map_t; + + const dc_map_t& getPresets(); + bool getPreset(const std::string name, LLWLDayCycle& day_cycle); + bool getPreset(const std::string name, LLSD& day_cycle); + +private: + friend class LLSingleton; + /*virtual*/ void initSingleton(); + + void loadAllPresets(); + void loadPresets(const std::string& dir); + bool loadPreset(const std::string& path); + + static std::string getSysDir(); + static std::string getUserDir(); + + dc_map_t mDayCycleMap; +}; + +#endif // LL_LLDAYCYCLEMANAGER_H diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index a08ca88459..f12c3e54ff 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -764,12 +764,6 @@ void LLEnvManagerNew::dumpUserPrefs() LL_DEBUGS("Windlight") << "UseDayCycle: " << gSavedSettings.getBOOL("UseDayCycle") << LL_ENDL; } -// static -LLSD LLEnvManagerNew::getDayCycleByName(const std::string name) -{ - return LLWLDayCycle::loadCycleDataFromFile(name + ".xml"); -} - void LLEnvManagerNew::requestRegionSettings() { LLEnvironmentRequest::initiate(); diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 52b645b535..223654151b 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -293,9 +293,6 @@ public: bool use_region_settings); void dumpUserPrefs(); - // Common interface to the wl/water managers. - static LLSD getDayCycleByName(const std::string name); - // Misc. void requestRegionSettings(); bool sendRegionSettings(const LLEnvironmentSettings& new_settings); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index cbbbed9830..f097f70143 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -31,6 +31,7 @@ #include "llcombobox.h" #include "llradiogroup.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llwaterparammanager.h" #include "llwlparamset.h" @@ -204,6 +205,9 @@ void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() { mDayCyclePresetCombo->removeall(); - std::string day_cycle_name = LLEnvManagerNew::getInstance()->getDayCycleName(); - mDayCyclePresetCombo->add(day_cycle_name); + const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); + for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + { + mDayCyclePresetCombo->add(it->first); + } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index ff34e21c2f..6a5b577396 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -52,6 +52,7 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llfilepicker.h" #include "llfloaterdaycycle.h" @@ -3350,14 +3351,18 @@ void LLPanelEnvironmentInfo::populateDayCyclesList() llassert(region != NULL); LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); - mDayCyclePresetCombo->add(region->getName(), key.toLLSD()); + mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); mDayCyclePresetCombo->addSeparator(); } // Add local day cycles. - // *TODO: multiple local day cycles support - LLWLParamKey key("Default", LLEnvKey::SCOPE_LOCAL); - mDayCyclePresetCombo->add("Default", key.toLLSD()); + const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); + for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + { + std::string name = it->first; + LLWLParamKey key(name, LLEnvKey::SCOPE_LOCAL); + mDayCyclePresetCombo->add(name, key.toStringVal()); + } // Current day cycle is already selected. } @@ -3421,7 +3426,8 @@ void LLPanelEnvironmentInfo::onBtnSave() } else // use day cycle { - LLWLParamKey dc(mDayCyclePresetCombo->getValue()); + std::string preset_key(mDayCyclePresetCombo->getValue().asString()); + LLWLParamKey dc(preset_key); LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle @@ -3431,8 +3437,11 @@ void LLPanelEnvironmentInfo::onBtnSave() } else // a local day cycle { - // *TODO: multiple local day cycles support - day_cycle = LLEnvManagerNew::instance().getDayCycleByName("Default"); + if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) + { + llwarns << "Error getting day cycle " << dc.name << llendl; + return; + } // Create sky map from the day cycle. { diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 7363392042..6ac63fb99e 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -100,9 +100,16 @@ void LLWLDayCycle::loadDayCycleFromFile(const std::string & fileName) // now load the file std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); - llinfos << "Loading DayCycle settings from " << pathName << llendl; + + return loadDayCycleFromPath(pathName); +} + +// static +LLSD LLWLDayCycle::loadDayCycleFromPath(const std::string& file_path) +{ + LL_INFOS("Windlight") << "Loading DayCycle settings from " << file_path << LL_ENDL; - llifstream day_cycle_xml(pathName); + llifstream day_cycle_xml(file_path); if (day_cycle_xml.is_open()) { // load and parse it diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index 36b5160a58..56bd66f114 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -68,6 +68,9 @@ public: /// load the LLSD data from a file (returns the undefined LLSD if not found) static LLSD loadCycleDataFromFile(const std::string & fileName); + /// load the LLSD data from a file specified by full path + static LLSD loadDayCycleFromPath(const std::string& file_path); + /// get the LLSD data for this day cycle LLSD asLLSD(); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index ec7889cb93..396c61b4b6 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -50,6 +50,7 @@ #include "llagent.h" #include "llviewerregion.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llwlparamset.h" #include "llpostprocess.h" @@ -613,7 +614,11 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) { if (LLEnvManagerNew::instance().getUseDayCycle()) { - applyDayCycle(LLEnvManagerNew::instance().getDayCycleName()); + if (!applyDayCycle(LLEnvManagerNew::instance().getDayCycleName())) + { + // *TODO: fix user prefs + applyDefaults(); + } } else { @@ -627,14 +632,21 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) void LLWLParamManager::applyDefaults() { - applyDayCycle("Default"); + llassert(applyDayCycle("Default") == true); } -void LLWLParamManager::applyDayCycle(const std::string& day_cycle) +bool LLWLParamManager::applyDayCycle(const std::string& day_cycle) { LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - mDay.loadDayCycleFromFile(day_cycle + ".xml"); + + if (!LLDayCycleManager::instance().getPreset(day_cycle, mDay)) + { + llwarns << "No day cycle named " << day_cycle << llendl; + return false; + } + resetAnimator(0.5, true); // set to noon and start animator + return true; } void LLWLParamManager::resetAnimator(F32 curTime, bool run) diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 35acb7c5d6..eb810a4086 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -246,7 +246,7 @@ public: void applyDefaults(); /// apply default sky params - void applyDayCycle(const std::string& day); + bool applyDayCycle(const std::string& day); // get where the light is pointing inline LLVector4 getLightDir(void) const; -- cgit v1.2.3 From 0eb13bb6824d520fe66e85cba9168a94f4d27635 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 26 May 2011 11:30:39 -0400 Subject: storm-1189: remove more of the code for classic clouds --- indra/newview/CMakeLists.txt | 87 +++--- indra/newview/llcloud.cpp | 538 ----------------------------------- indra/newview/llcloud.h | 199 ------------- indra/newview/lldrawable.cpp | 5 - indra/newview/lldrawpool.cpp | 1 - indra/newview/lldrawpoolalpha.cpp | 1 - indra/newview/lldrawpoolclouds.cpp | 97 ------- indra/newview/lldrawpoolclouds.h | 54 ---- indra/newview/llspatialpartition.cpp | 2 +- indra/newview/llspatialpartition.h | 7 - indra/newview/llstartup.cpp | 6 - indra/newview/llviewerobject.cpp | 3 - indra/newview/llviewerobject.h | 2 +- indra/newview/llviewerobjectlist.cpp | 3 +- indra/newview/llviewerregion.cpp | 2 - indra/newview/llviewerregion.h | 1 - indra/newview/llvoclouds.cpp | 293 ------------------- indra/newview/llvoclouds.h | 79 ----- indra/newview/llworld.cpp | 70 ----- 19 files changed, 45 insertions(+), 1405 deletions(-) delete mode 100644 indra/newview/llcloud.cpp delete mode 100644 indra/newview/llcloud.h delete mode 100644 indra/newview/lldrawpoolclouds.cpp delete mode 100644 indra/newview/lldrawpoolclouds.h delete mode 100644 indra/newview/llvoclouds.cpp delete mode 100644 indra/newview/llvoclouds.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5a9ee92b0c..e8ee43d7a0 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -517,7 +517,7 @@ set(viewer_SOURCE_FILES llviewerfloaterreg.cpp llviewerfoldertype.cpp llviewergenericmessage.cpp - llviewergesture.cpp + llviewergesture.cpp llviewerhelp.cpp llviewerhelputil.cpp llviewerhome.cpp @@ -564,7 +564,6 @@ set(viewer_SOURCE_FILES llvoavatardefines.cpp llvoavatarself.cpp llvocache.cpp - llvoclouds.cpp llvograss.cpp llvoground.cpp llvoicecallhandler.cpp @@ -691,7 +690,6 @@ set(viewer_HEADER_FILES lldrawpoolalpha.h lldrawpoolavatar.h lldrawpoolbump.h - lldrawpoolclouds.h lldrawpoolground.h lldrawpoolsimple.h lldrawpoolsky.h @@ -995,7 +993,7 @@ set(viewer_HEADER_FILES llsurface.h llsurfacepatch.h llsyswellitem.h - llsyswellwindow.h + llsyswellwindow.h lltable.h llteleporthistory.h llteleporthistorystorage.h @@ -1067,7 +1065,7 @@ set(viewer_HEADER_FILES llviewerfloaterreg.h llviewerfoldertype.h llviewergenericmessage.h - llviewergesture.h + llviewergesture.h llviewerhelp.h llviewerhome.h llviewerinventory.h @@ -1111,7 +1109,6 @@ set(viewer_HEADER_FILES llvoavatardefines.h llvoavatarself.h llvocache.h - llvoclouds.h llvograss.h llvoground.h llvoicechannel.h @@ -1223,7 +1220,7 @@ if (WINDOWS) # precompiled header configuration # llviewerprecompiledheaders.cpp generates # the .pch file. - # All sources added to viewer_SOURCE_FILES + # All sources added to viewer_SOURCE_FILES # at this point use it. if(USE_PRECOMPILED_HEADERS) set_source_files_properties(llviewerprecompiledheaders.cpp @@ -1232,7 +1229,7 @@ if (WINDOWS) ) set(viewer_SOURCE_FILES "${viewer_SOURCE_FILES}" llviewerprecompiledheaders.cpp) endif(USE_PRECOMPILED_HEADERS) - + # Add resource files to the project. # viewerRes.rc is the only buildable file, but # the rest are all dependencies of it. @@ -1277,8 +1274,8 @@ if (WINDOWS) set_source_files_properties(${viewer_RESOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) - set(viewer_RESOURCE_FILES - res/viewerRes.rc + set(viewer_RESOURCE_FILES + res/viewerRes.rc ${viewer_RESOURCE_FILES} ) @@ -1286,7 +1283,7 @@ if (WINDOWS) if (NOT STANDALONE) list(APPEND viewer_SOURCE_FILES ${viewer_RESOURCE_FILES}) - endif (NOT STANDALONE) + endif (NOT STANDALONE) find_library(DINPUT_LIBRARY dinput8 ${DIRECTX_LIBRARY_DIR}) find_library(DXGUID_LIBRARY dxguid ${DIRECTX_LIBRARY_DIR}) @@ -1495,7 +1492,7 @@ if (WINDOWS) ${SHARED_LIB_STAGING_DIR}/Debug/libtcmalloc_minimal-debug.dll ) endif(USE_GOOGLE_PERFTOOLS) - + set(COPY_INPUT_DEPENDENCIES # The following commented dependencies are determined at variably at build time. Can't do this here. @@ -1593,24 +1590,24 @@ if (WINDOWS) --grid=${GRID} --source=${CMAKE_CURRENT_SOURCE_DIR} --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/copy_touched.bat - DEPENDS + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py stage_third_party_libs ${COPY_INPUT_DEPENDENCIES} COMMENT "Performing viewer_manifest copy" ) - - add_custom_target(copy_w_viewer_manifest ALL DEPENDS ${CMAKE_CFG_INTDIR}/copy_touched.bat) + + add_custom_target(copy_w_viewer_manifest ALL DEPENDS ${CMAKE_CFG_INTDIR}/copy_touched.bat) add_dependencies(${VIEWER_BINARY_NAME} stage_third_party_libs llcommon copy_w_viewer_manifest) - + if (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts) add_dependencies(${VIEWER_BINARY_NAME} copy_win_scripts) endif (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts) - - add_dependencies(${VIEWER_BINARY_NAME} - SLPlugin - windows-updater + + add_dependencies(${VIEWER_BINARY_NAME} + SLPlugin + windows-updater windows-crash-logger ) @@ -1620,7 +1617,7 @@ if (WINDOWS) TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/vstool/vstool.exe ARGS - --solution + --solution ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.sln --workingdir ${VIEWER_BINARY_NAME} @@ -1638,12 +1635,12 @@ if (WINDOWS) ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CFG_INTDIR} - DEPENDS - lleventhost + DEPENDS + lleventhost ${EVENT_HOST_SCRIPTS} ${CMAKE_CURRENT_SOURCE_DIR}/event_host_manifest.py ) - + add_custom_command( OUTPUT ${CMAKE_CFG_INTDIR}/touched.bat COMMAND ${PYTHON_EXECUTABLE} @@ -1659,15 +1656,15 @@ if (WINDOWS) --login_channel=${VIEWER_LOGIN_CHANNEL} --source=${CMAKE_CURRENT_SOURCE_DIR} --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/touched.bat - DEPENDS - ${VIEWER_BINARY_NAME} + DEPENDS + ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ${COPY_INPUT_DEPENDENCIES} ) - add_custom_target(package ALL DEPENDS + add_custom_target(package ALL DEPENDS ${CMAKE_CFG_INTDIR}/touched.bat - windows-setup-build-all + windows-setup-build-all ) # temporarily disable packaging of event_host until hg subrepos get # sorted out on the parabuild cluster... @@ -1735,7 +1732,7 @@ else (USE_KDU) ${LLIMAGEJ2COJ_LIBRARIES} ) endif (USE_KDU) - + build_version(viewer) set(ARTWORK_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH @@ -1794,13 +1791,13 @@ if (LINUX) --dest=${CMAKE_CURRENT_BINARY_DIR}/packaged --grid=${GRID} --source=${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ${COPY_INPUT_DEPENDENCIES} COMMENT "Performing viewer_manifest copy" ) - - add_custom_target(copy_l_viewer_manifest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.copy_touched) + + add_custom_target(copy_l_viewer_manifest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.copy_touched) if (PACKAGE) add_custom_target(package ALL DEPENDS ${product}.tar.bz2) @@ -1845,7 +1842,7 @@ if (DARWIN) add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit mac-updater mac-crash-logger) if (PACKAGE) - add_custom_target(package ALL DEPENDS ${VIEWER_BINARY_NAME}) + add_custom_target(package ALL DEPENDS ${VIEWER_BINARY_NAME}) add_custom_command( TARGET package POST_BUILD @@ -1940,7 +1937,7 @@ if (LL_TESTS) ) ################################################## - # DISABLING PRECOMPILED HEADERS USAGE FOR TESTS + # DISABLING PRECOMPILED HEADERS USAGE FOR TESTS ################################################## # if(USE_PRECOMPILED_HEADERS) # set_source_files_properties( @@ -1954,33 +1951,33 @@ if (LL_TESTS) #set(TEST_DEBUG on) set(test_sources llcapabilitylistener.cpp) ################################################## - # DISABLING PRECOMPILED HEADERS USAGE FOR TESTS + # DISABLING PRECOMPILED HEADERS USAGE FOR TESTS ################################################## # if(USE_PRECOMPILED_HEADERS) # set(test_sources "${test_sources}" llviewerprecompiledheaders.cpp) # endif(USE_PRECOMPILED_HEADERS) - set(test_libs - ${LLMESSAGE_LIBRARIES} - ${WINDOWS_LIBRARIES} + set(test_libs + ${LLMESSAGE_LIBRARIES} + ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} - ${LLCOMMON_LIBRARIES} + ${LLCOMMON_LIBRARIES} ${GOOGLEMOCK_LIBRARIES} ) - LL_ADD_INTEGRATION_TEST(llcapabilitylistener - "${test_sources}" + LL_ADD_INTEGRATION_TEST(llcapabilitylistener + "${test_sources}" "${test_libs}" ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/llmessage/tests/test_llsdmessage_peer.py" ) - set(test_libs - ${LLMESSAGE_LIBRARIES} - ${WINDOWS_LIBRARIES} + set(test_libs + ${LLMESSAGE_LIBRARIES} + ${WINDOWS_LIBRARIES} ${LLVFS_LIBRARIES} ${LLMATH_LIBRARIES} - ${LLCOMMON_LIBRARIES} + ${LLCOMMON_LIBRARIES} ${GOOGLEMOCK_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} diff --git a/indra/newview/llcloud.cpp b/indra/newview/llcloud.cpp deleted file mode 100644 index cda0f6e4a2..0000000000 --- a/indra/newview/llcloud.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/** - * @file llcloud.cpp - * @brief Implementation of viewer LLCloudLayer class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llmath.h" -//#include "vmath.h" -#include "v3math.h" -#include "v4math.h" -#include "llquaternion.h" -#include "llrand.h" -#include "v4color.h" - -#include "llwind.h" -#include "llcloud.h" -#include "llgl.h" -#include "llviewerobjectlist.h" -#include "llvoclouds.h" -#include "llvosky.h" -#include "llsky.h" -#include "llviewerregion.h" -#include "patch_dct.h" -#include "patch_code.h" -#include "llglheaders.h" -#include "pipeline.h" -#include "lldrawpool.h" -#include "llworld.h" - -extern LLPipeline gPipeline; - -const F32 CLOUD_UPDATE_RATE = 1.0f; // Global time dilation for clouds -const F32 CLOUD_GROW_RATE = 0.05f; -const F32 CLOUD_DECAY_RATE = -0.05f; -const F32 CLOUD_VELOCITY_SCALE = 0.01f; -const F32 CLOUD_DENSITY = 25.f; -const S32 CLOUD_COUNT_MAX = 20; -const F32 CLOUD_HEIGHT_RANGE = 48.f; -const F32 CLOUD_HEIGHT_MEAN = 192.f; - -enum -{ - LL_PUFF_GROWING = 0, - LL_PUFF_DYING = 1 -}; - -// Used for patch decoder -S32 gBuffer[16*16]; - - -//static -S32 LLCloudPuff::sPuffCount = 0; - -LLCloudPuff::LLCloudPuff() : - mAlpha(0.01f), - mRate(CLOUD_GROW_RATE*CLOUD_UPDATE_RATE), - mLifeState(LL_PUFF_GROWING) -{ -} - -LLCloudGroup::LLCloudGroup() : - mCloudLayerp(NULL), - mDensity(0.f), - mTargetPuffCount(0), - mVOCloudsp(NULL) -{ -} - -void LLCloudGroup::cleanup() -{ - if (mVOCloudsp) - { - if (!mVOCloudsp->isDead()) - { - gObjectList.killObject(mVOCloudsp); - } - mVOCloudsp = NULL; - } -} - -void LLCloudGroup::setCenterRegion(const LLVector3 ¢er) -{ - mCenterRegion = center; -} - -void LLCloudGroup::updatePuffs(const F32 dt) -{ - mDensity = mCloudLayerp->getDensityRegion(mCenterRegion); - - if (!mVOCloudsp) - { - mVOCloudsp = (LLVOClouds *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_CLOUDS, mCloudLayerp->getRegion()); - mVOCloudsp->setCloudGroup(this); - mVOCloudsp->setPositionRegion(mCenterRegion); - mVOCloudsp->setScale(LLVector3(256.f/CLOUD_GROUPS_PER_EDGE + CLOUD_PUFF_WIDTH, - 256.f/CLOUD_GROUPS_PER_EDGE + CLOUD_PUFF_WIDTH, - CLOUD_HEIGHT_RANGE + CLOUD_PUFF_HEIGHT)*0.5f); - gPipeline.createObject(mVOCloudsp); - } - - LLVector3 velocity; - LLVector3d vel_d; - // Update the positions of all of the clouds - for (U32 i = 0; i < mCloudPuffs.size(); i++) - { - LLCloudPuff &puff = mCloudPuffs[i]; - velocity = mCloudLayerp->getRegion()->mWind.getCloudVelocity(mCloudLayerp->getRegion()->getPosRegionFromGlobal(puff.mPositionGlobal)); - velocity *= CLOUD_VELOCITY_SCALE*CLOUD_UPDATE_RATE; - vel_d.setVec(velocity); - mCloudPuffs[i].mPositionGlobal += vel_d; - mCloudPuffs[i].mAlpha += mCloudPuffs[i].mRate * dt; - mCloudPuffs[i].mAlpha = llmin(1.f, mCloudPuffs[i].mAlpha); - mCloudPuffs[i].mAlpha = llmax(0.f, mCloudPuffs[i].mAlpha); - } -} - -void LLCloudGroup::updatePuffOwnership() -{ - U32 i = 0; - while (i < mCloudPuffs.size()) - { - if (mCloudPuffs[i].getLifeState() == LL_PUFF_DYING) - { - i++; - continue; - } - if (inGroup(mCloudPuffs[i])) - { - i++; - continue; - } - - //llinfos << "Cloud moving to new group" << llendl; - LLCloudGroup *new_cgp = LLWorld::getInstance()->findCloudGroup(mCloudPuffs[i]); - if (!new_cgp) - { - //llinfos << "Killing puff not in group" << llendl; - mCloudPuffs[i].setLifeState(LL_PUFF_DYING); - mCloudPuffs[i].mRate = CLOUD_DECAY_RATE*CLOUD_UPDATE_RATE; - i++; - continue; - } - //llinfos << "Puff handed off!" << llendl; - LLCloudPuff puff; - puff.mPositionGlobal = mCloudPuffs[i].mPositionGlobal; - puff.mAlpha = mCloudPuffs[i].mAlpha; - mCloudPuffs.erase(mCloudPuffs.begin() + i); - new_cgp->mCloudPuffs.push_back(puff); - } - - //llinfos << "Puff count: " << LLCloudPuff::sPuffCount << llendl; -} - -void LLCloudGroup::updatePuffCount() -{ - if (!mVOCloudsp) - { - return; - } - S32 i; - S32 target_puff_count = llround(CLOUD_DENSITY * mDensity); - target_puff_count = llmax(0, target_puff_count); - target_puff_count = llmin(CLOUD_COUNT_MAX, target_puff_count); - S32 current_puff_count = (S32) mCloudPuffs.size(); - // Create a new cloud if we need one - if (current_puff_count < target_puff_count) - { - LLVector3d puff_pos_global; - mCloudPuffs.resize(target_puff_count); - for (i = current_puff_count; i < target_puff_count; i++) - { - puff_pos_global = mVOCloudsp->getPositionGlobal(); - F32 x = ll_frand(256.f/CLOUD_GROUPS_PER_EDGE) - 128.f/CLOUD_GROUPS_PER_EDGE; - F32 y = ll_frand(256.f/CLOUD_GROUPS_PER_EDGE) - 128.f/CLOUD_GROUPS_PER_EDGE; - F32 z = ll_frand(CLOUD_HEIGHT_RANGE) - 0.5f*CLOUD_HEIGHT_RANGE; - puff_pos_global += LLVector3d(x, y, z); - mCloudPuffs[i].mPositionGlobal = puff_pos_global; - mCloudPuffs[i].mAlpha = 0.01f; - LLCloudPuff::sPuffCount++; - } - } - - // Count the number of live puffs - S32 live_puff_count = 0; - for (i = 0; i < (S32) mCloudPuffs.size(); i++) - { - if (mCloudPuffs[i].getLifeState() != LL_PUFF_DYING) - { - live_puff_count++; - } - } - - - // Start killing enough puffs so the live puff count == target puff count - S32 new_dying_count = llmax(0, live_puff_count - target_puff_count); - i = 0; - while (new_dying_count > 0) - { - if (mCloudPuffs[i].getLifeState() != LL_PUFF_DYING) - { - //llinfos << "Killing extra live cloud" << llendl; - mCloudPuffs[i].setLifeState(LL_PUFF_DYING); - mCloudPuffs[i].mRate = CLOUD_DECAY_RATE*CLOUD_UPDATE_RATE; - new_dying_count--; - } - i++; - } - - // Remove fully dead puffs - i = 0; - while (i < (S32) mCloudPuffs.size()) - { - if (mCloudPuffs[i].isDead()) - { - //llinfos << "Removing dead puff!" << llendl; - mCloudPuffs.erase(mCloudPuffs.begin() + i); - LLCloudPuff::sPuffCount--; - } - else - { - i++; - } - } -} - -BOOL LLCloudGroup::inGroup(const LLCloudPuff &puff) const -{ - // Do min/max check on center of the cloud puff - F32 min_x, min_y, max_x, max_y; - F32 delta = 128.f/CLOUD_GROUPS_PER_EDGE; - min_x = mCenterRegion.mV[VX] - delta; - min_y = mCenterRegion.mV[VY] - delta; - max_x = mCenterRegion.mV[VX] + delta; - max_y = mCenterRegion.mV[VY] + delta; - - LLVector3 pos_region = mCloudLayerp->getRegion()->getPosRegionFromGlobal(puff.getPositionGlobal()); - - if ((pos_region.mV[VX] < min_x) - || (pos_region.mV[VY] < min_y) - || (pos_region.mV[VX] > max_x) - || (pos_region.mV[VY] > max_y)) - { - return FALSE; - } - return TRUE; -} - -LLCloudLayer::LLCloudLayer() -: mOriginGlobal(0.0f, 0.0f, 0.0f), - mMetersPerEdge(1.0f), - mMetersPerGrid(1.0f), - mWindp(NULL), - mDensityp(NULL) -{ - S32 i, j; - for (i = 0; i < 4; i++) - { - mNeighbors[i] = NULL; - } - - F32 x, y; - for (i = 0; i < CLOUD_GROUPS_PER_EDGE; i++) - { - y = (0.5f + i)*(256.f/CLOUD_GROUPS_PER_EDGE); - for (j = 0; j < CLOUD_GROUPS_PER_EDGE; j++) - { - x = (0.5f + j)*(256.f/CLOUD_GROUPS_PER_EDGE); - - mCloudGroups[i][j].setCloudLayerp(this); - mCloudGroups[i][j].setCenterRegion(LLVector3(x, y, CLOUD_HEIGHT_MEAN)); - } - } -} - - - -LLCloudLayer::~LLCloudLayer() -{ - destroy(); -} - - -void LLCloudLayer::create(LLViewerRegion *regionp) -{ - llassert(regionp); - - mRegionp = regionp; - mDensityp = new F32 [CLOUD_GRIDS_PER_EDGE * CLOUD_GRIDS_PER_EDGE]; - - U32 i; - for (i = 0; i < CLOUD_GRIDS_PER_EDGE*CLOUD_GRIDS_PER_EDGE; i++) - { - mDensityp[i] = 0.f; - } -} - -void LLCloudLayer::setRegion(LLViewerRegion *regionp) -{ - mRegionp = regionp; -} - -void LLCloudLayer::destroy() -{ - reset(); - - delete [] mDensityp; - mDensityp = NULL; - mWindp = NULL; -} - - -void LLCloudLayer::reset() -{ - // Kill all of the existing puffs - S32 i, j; - - for (i = 0; i < CLOUD_GROUPS_PER_EDGE; i++) - { - for (j = 0; j < CLOUD_GROUPS_PER_EDGE; j++) - { - mCloudGroups[i][j].cleanup(); - } - } -} - -void LLCloudLayer::setWindPointer(LLWind *windp) -{ - if (mWindp) - { - mWindp->setCloudDensityPointer(NULL); - } - mWindp = windp; - if (mWindp) - { - mWindp->setCloudDensityPointer(mDensityp); - } -} - - -void LLCloudLayer::setWidth(F32 width) -{ - mMetersPerEdge = width; - mMetersPerGrid = width / CLOUD_GRIDS_PER_EDGE; -} - - -F32 LLCloudLayer::getDensityRegion(const LLVector3 &pos_region) -{ - // "position" is region-local - S32 i, j, ii, jj; - - i = lltrunc(pos_region.mV[VX] / mMetersPerGrid); - j = lltrunc(pos_region.mV[VY] / mMetersPerGrid); - ii = i + 1; - jj = j + 1; - - - // clamp - if (i >= (S32)CLOUD_GRIDS_PER_EDGE) - { - i = CLOUD_GRIDS_PER_EDGE - 1; - ii = i; - } - else if (i < 0) - { - i = 0; - ii = i; - } - else if (ii >= (S32)CLOUD_GRIDS_PER_EDGE || ii < 0) - { - ii = i; - } - - if (j >= (S32)CLOUD_GRIDS_PER_EDGE) - { - j = CLOUD_GRIDS_PER_EDGE - 1; - jj = j; - } - else if (j < 0) - { - j = 0; - jj = j; - } - else if (jj >= (S32)CLOUD_GRIDS_PER_EDGE || jj < 0) - { - jj = j; - } - - F32 dx = (pos_region.mV[VX] - (F32) i * mMetersPerGrid) / mMetersPerGrid; - F32 dy = (pos_region.mV[VY] - (F32) j * mMetersPerGrid) / mMetersPerGrid; - F32 omdx = 1.0f - dx; - F32 omdy = 1.0f - dy; - - F32 density = dx * dy * *(mDensityp + ii + jj * CLOUD_GRIDS_PER_EDGE) + - dx * omdy * *(mDensityp + i + jj * CLOUD_GRIDS_PER_EDGE) + - omdx * dy * *(mDensityp + ii + j * CLOUD_GRIDS_PER_EDGE) + - omdx * omdy * *(mDensityp + i + j * CLOUD_GRIDS_PER_EDGE); - - return density; -} - -void LLCloudLayer::decompress(LLBitPack &bitpack, LLGroupHeader *group_headerp) -{ - LLPatchHeader patch_header; - - init_patch_decompressor(group_headerp->patch_size); - - // Don't use the packed group_header stride because the strides used on - // simulator and viewer are not equal. - group_headerp->stride = group_headerp->patch_size; // offset required to step up one row - set_group_of_patch_header(group_headerp); - - decode_patch_header(bitpack, &patch_header); - decode_patch(bitpack, gBuffer); - decompress_patch(mDensityp, gBuffer, &patch_header); -} - -void LLCloudLayer::updatePuffs(const F32 dt) -{ - // We want to iterate through all of the cloud groups - // and update their density targets - - S32 i, j; - - for (i = 0; i < CLOUD_GROUPS_PER_EDGE; i++) - { - for (j = 0; j < CLOUD_GROUPS_PER_EDGE; j++) - { - mCloudGroups[i][j].updatePuffs(dt); - } - } -} - -void LLCloudLayer::updatePuffOwnership() -{ - S32 i, j; - - for (i = 0; i < CLOUD_GROUPS_PER_EDGE; i++) - { - for (j = 0; j < CLOUD_GROUPS_PER_EDGE; j++) - { - mCloudGroups[i][j].updatePuffOwnership(); - } - } -} - -void LLCloudLayer::updatePuffCount() -{ - S32 i, j; - - for (i = 0; i < CLOUD_GROUPS_PER_EDGE; i++) - { - for (j = 0; j < CLOUD_GROUPS_PER_EDGE; j++) - { - mCloudGroups[i][j].updatePuffCount(); - } - } -} - -LLCloudGroup *LLCloudLayer::findCloudGroup(const LLCloudPuff &puff) -{ - S32 i, j; - - for (i = 0; i < CLOUD_GROUPS_PER_EDGE; i++) - { - for (j = 0; j < CLOUD_GROUPS_PER_EDGE; j++) - { - if (mCloudGroups[i][j].inGroup(puff)) - { - return &(mCloudGroups[i][j]); - } - } - } - return NULL; -} - - - -void LLCloudLayer::connectNeighbor(LLCloudLayer *cloudp, U32 direction) -{ - if (direction >= 4) - { - // Only care about cardinal 4 directions. - return; - } - - mNeighbors[direction] = cloudp; - if (cloudp) - mNeighbors[direction]->mNeighbors[gDirOpposite[direction]] = this; -} - - -void LLCloudLayer::disconnectNeighbor(U32 direction) -{ - if (direction >= 4) - { - // Only care about cardinal 4 directions. - return; - } - - if (mNeighbors[direction]) - { - mNeighbors[direction]->mNeighbors[gDirOpposite[direction]] = NULL; - mNeighbors[direction] = NULL; - } -} - - -void LLCloudLayer::disconnectAllNeighbors() -{ - S32 i; - for (i = 0; i < 4; i++) - { - disconnectNeighbor(i); - } -} diff --git a/indra/newview/llcloud.h b/indra/newview/llcloud.h deleted file mode 100644 index 0435ba1ece..0000000000 --- a/indra/newview/llcloud.h +++ /dev/null @@ -1,199 +0,0 @@ -/** - * @file llcloud.h - * @brief Description of viewer LLCloudLayer class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLCLOUD_H -#define LL_LLCLOUD_H - -// Some ideas on how clouds should work -// -// Each region has a cloud layer -// Each cloud layer has pre-allocated space for N clouds -// The LLSky class knows the max number of clouds to render M. -// All clouds use the same texture, but the tex-coords can take on 8 configurations -// (four rotations, front and back) -// -// The sky's part -// -------------- -// The sky knows that A clouds have been assigned to regions and there are B left over. -// Divide B by number of active regions to get C. -// Ask each region to add C more clouds and return total number D. -// Add up all the D's to get a new A. -// -// The cloud layer's part -// ---------------------- -// The cloud layer is a grid of possibility. Each grid's value represents the probablility -// (0.0 to 1.0) that a cloud placement query will succeed. -// -// The sky asks the region to add C more clouds. -// The cloud layer tries a total of E times to place clouds and returns total cloud count. -// -// Clouds move according to local wind velocity. -// If a cloud moves out of region then it's location is sent to neighbor region -// or it is allowed to drift and decay. -// -// The clouds in non-visible regions do not propagate every frame. -// Each frame one non-visible region is allowed to propagate it's clouds -// (might have to check to see if incoming cloud was already visible or not). -// -// - -#include "llmath.h" -//#include "vmath.h" -#include "v3math.h" -#include "v3dmath.h" -#include "v4math.h" -#include "v4color.h" -#include "llpointer.h" -#include "lldarray.h" - -#include "llframetimer.h" - -const U32 CLOUD_GRIDS_PER_EDGE = 16; - -const F32 CLOUD_PUFF_WIDTH = 64.f; -const F32 CLOUD_PUFF_HEIGHT = 48.f; - -class LLWind; -class LLVOClouds; -class LLViewerRegion; -class LLCloudLayer; -class LLBitPack; -class LLGroupHeader; - -const S32 CLOUD_GROUPS_PER_EDGE = 4; - -class LLCloudPuff -{ -public: - LLCloudPuff(); - - const LLVector3d &getPositionGlobal() const { return mPositionGlobal; } - friend class LLCloudGroup; - - void updatePuffs(const F32 dt); - void updatePuffOwnership(); - - F32 getAlpha() const { return mAlpha; } - U32 getLifeState() const { return mLifeState; } - void setLifeState(const U32 state) { mLifeState = state; } - BOOL isDead() const { return mAlpha <= 0.f; } - - - static S32 sPuffCount; -protected: - F32 mAlpha; - F32 mRate; - LLVector3d mPositionGlobal; - - BOOL mLifeState; -}; - -class LLCloudGroup -{ -public: - LLCloudGroup(); - - void cleanup(); - - void setCloudLayerp(LLCloudLayer *clp) { mCloudLayerp = clp; } - void setCenterRegion(const LLVector3 ¢er); - - void updatePuffs(const F32 dt); - void updatePuffOwnership(); - void updatePuffCount(); - - BOOL inGroup(const LLCloudPuff &puff) const; - - F32 getDensity() const { return mDensity; } - S32 getNumPuffs() const { return (S32) mCloudPuffs.size(); } - const LLCloudPuff &getPuff(const S32 i) { return mCloudPuffs[i]; } -protected: - LLCloudLayer *mCloudLayerp; - LLVector3 mCenterRegion; - F32 mDensity; - S32 mTargetPuffCount; - - std::vector mCloudPuffs; - LLPointer mVOCloudsp; -}; - - -class LLCloudLayer -{ -public: - LLCloudLayer(); - ~LLCloudLayer(); - - void create(LLViewerRegion *regionp); - void destroy(); - - void reset(); // Clears all active cloud puffs - - - void updatePuffs(const F32 dt); - void updatePuffOwnership(); - void updatePuffCount(); - - LLCloudGroup *findCloudGroup(const LLCloudPuff &puff); - - void setRegion(LLViewerRegion *regionp); - LLViewerRegion* getRegion() const { return mRegionp; } - void setWindPointer(LLWind *windp); - void setOriginGlobal(const LLVector3d &origin_global) { mOriginGlobal = origin_global; } - void setWidth(F32 width); - - void setBrightness(F32 brightness); - void setSunColor(const LLColor4 &color); - - F32 getDensityRegion(const LLVector3 &pos_region); // "position" is in local coordinates - - void decompress(LLBitPack &bitpack, LLGroupHeader *group_header); - - LLCloudLayer* getNeighbor(const S32 n) const { return mNeighbors[n]; } - - void connectNeighbor(LLCloudLayer *cloudp, U32 direction); - void disconnectNeighbor(U32 direction); - void disconnectAllNeighbors(); - -public: - LLVector3d mOriginGlobal; - F32 mMetersPerEdge; - F32 mMetersPerGrid; - - - F32 mMaxAlpha; // The max cloud puff _render_ alpha - -protected: - LLCloudLayer *mNeighbors[4]; - LLWind *mWindp; - LLViewerRegion *mRegionp; - F32 *mDensityp; // the probability density grid - - LLCloudGroup mCloudGroups[CLOUD_GROUPS_PER_EDGE][CLOUD_GROUPS_PER_EDGE]; -}; - - -#endif diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index bdc12ec0e3..8f7b992093 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -385,7 +385,6 @@ void LLDrawable::makeActive() pcode == LLViewerObject::LL_VO_SURFACE_PATCH || pcode == LLViewerObject::LL_VO_PART_GROUP || pcode == LLViewerObject::LL_VO_HUD_PART_GROUP || - pcode == LLViewerObject::LL_VO_CLOUDS || pcode == LLViewerObject::LL_VO_GROUND || pcode == LLViewerObject::LL_VO_SKY) { @@ -1513,10 +1512,6 @@ BOOL LLDrawable::isAnimating() const { return TRUE; } - if (mVObjp->getPCode() == LLViewerObject::LL_VO_CLOUDS) - { - return TRUE; - } if (!isRoot() && !mVObjp->getAngularVelocity().isExactlyZero()) { diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 25e4bc847c..08b31d687b 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -35,7 +35,6 @@ #include "lldrawpoolalpha.h" #include "lldrawpoolavatar.h" #include "lldrawpoolbump.h" -#include "lldrawpoolclouds.h" #include "lldrawpoolground.h" #include "lldrawpoolsimple.h" #include "lldrawpoolsky.h" diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 8b5a2ce781..9fb7968d96 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -357,7 +357,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow. // All particle systems seem to come off the wire with texture entries which claim that they glow. This is probably a bug in the data. Suppress. group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE && - group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_CLOUD && group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE; LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA]; diff --git a/indra/newview/lldrawpoolclouds.cpp b/indra/newview/lldrawpoolclouds.cpp deleted file mode 100644 index 5db1d8cfed..0000000000 --- a/indra/newview/lldrawpoolclouds.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file lldrawpoolclouds.cpp - * @brief LLDrawPoolClouds class implementation - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "lldrawpoolclouds.h" - -#include "llface.h" -#include "llsky.h" -#include "llviewercamera.h" -#include "llvoclouds.h" -#include "pipeline.h" - -LLDrawPoolClouds::LLDrawPoolClouds() : - LLDrawPool(POOL_CLOUDS) -{ -} - -LLDrawPool *LLDrawPoolClouds::instancePool() -{ - return new LLDrawPoolClouds(); -} - -BOOL LLDrawPoolClouds::addFace(LLFace* face) -{ - llerrs << "WTF?" << llendl; - return FALSE; -} - -void LLDrawPoolClouds::enqueue(LLFace *facep) -{ - mDrawFace.push_back(facep); - facep->mDistance = (facep->mCenterAgent - gCamera->getOrigin()) * gCamera->getAtAxis(); -} - -void LLDrawPoolClouds::beginRenderPass(S32 pass) -{ - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); -} - -void LLDrawPoolClouds::prerender() -{ - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT); -} - -void LLDrawPoolClouds::render(S32 pass) -{ - LLFastTimer ftm(LLFastTimer::FTM_RENDER_CLOUDS); - if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS))) - { - return; - } - - if (mDrawFace.empty()) - { - return; - } - - LLGLSPipelineAlpha gls_pipeline_alpha; - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - glAlphaFunc(GL_GREATER,0.01f); - - gPipeline.enableLightsFullbright(LLColor4(1.f,1.f,1.f)); - - mDrawFace[0]->bindTexture(); - - std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); - - drawLoop(); -} - - diff --git a/indra/newview/lldrawpoolclouds.h b/indra/newview/lldrawpoolclouds.h deleted file mode 100644 index 019f11a795..0000000000 --- a/indra/newview/lldrawpoolclouds.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file lldrawpoolclouds.h - * @brief LLDrawPoolClouds class definition - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLDRAWPOOLCLOUDS_H -#define LL_LLDRAWPOOLCLOUDS_H - -#include "lldrawpool.h" - -class LLDrawPoolClouds : public LLDrawPool -{ -public: - enum - { - VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_NORMAL | - LLVertexBuffer::MAP_TEXCOORD0 - }; - - BOOL addFace(LLFace* face); - virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } - - LLDrawPoolClouds(); - - /*virtual*/ void prerender(); - /*virtual*/ LLDrawPool *instancePool(); - /*virtual*/ void enqueue(LLFace *face); - /*virtual*/ void beginRenderPass(S32 pass); - /*virtual*/ void render(S32 pass = 0); -}; - -#endif // LL_LLDRAWPOOLSKY_H diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index fa329eb0ae..cb82ad3209 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2818,7 +2818,7 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE) gGL.color4f(0,1,1,1); break; case LLViewerObject::LL_VO_CLOUDS: - gGL.color4f(0.5f,0.5f,0.5f,1.0f); + // no longer used break; case LLViewerObject::LL_VO_PART_GROUP: case LLViewerObject::LL_VO_HUD_PART_GROUP: diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 0d9cad914a..bc2bcd7c1d 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -662,13 +662,6 @@ public: LLGrassPartition(); }; -//spatial partition for clouds (implemented in LLVOClouds.cpp) -class LLCloudPartition : public LLParticlePartition -{ -public: - LLCloudPartition(); -}; - //class for wrangling geometry out of volumes (implemented in LLVOVolume.cpp) class LLVolumeGeometryManager: public LLGeometryManager { diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c6b73dae13..34614a4b78 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -163,7 +163,6 @@ #include "llviewerwindow.h" #include "llvoavatar.h" #include "llvoavatarself.h" -#include "llvoclouds.h" #include "llweb.h" #include "llworld.h" #include "llworldmapmessage.h" @@ -3149,11 +3148,6 @@ bool process_login_success_response() gMoonTextureID = id; } - id = global_textures["cloud_texture_id"]; - if(id.notNull()) - { - gCloudTextureID = id; - } } // Set the location of the snapshot sharing config endpoint diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 6d493bfcd5..c8ecd2577b 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -81,7 +81,6 @@ #include "llviewerwindow.h" // For getSpinAxis #include "llvoavatar.h" #include "llvoavatarself.h" -#include "llvoclouds.h" #include "llvograss.h" #include "llvoground.h" #include "llvolume.h" @@ -169,8 +168,6 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco res = NULL; break; case LL_PCODE_LEGACY_TEXT_BUBBLE: res = new LLVOTextBubble(id, pcode, regionp); break; - case LL_VO_CLOUDS: - res = new LLVOClouds(id, pcode, regionp); break; case LL_VO_SURFACE_PATCH: res = new LLVOSurfacePatch(id, pcode, regionp); break; case LL_VO_SKY: diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index e417343bec..ed31fd9477 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -546,7 +546,7 @@ public: // typedef enum e_vo_types { - LL_VO_CLOUDS = LL_PCODE_APP | 0x20, + LL_VO_CLOUDS = LL_PCODE_APP | 0x20, // no longer used LL_VO_SURFACE_PATCH = LL_PCODE_APP | 0x30, LL_VO_WL_SKY = LL_PCODE_APP | 0x40, LL_VO_SQUARE_TORUS = LL_PCODE_APP | 0x50, diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index ab2e07e4df..acacf63a1f 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -957,8 +957,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) iter != idle_list.end(); iter++) { objectp = *iter; - if (objectp->getPCode() == LLViewerObject::LL_VO_CLOUDS || - objectp->isAvatar()) + if (objectp->isAvatar()) { objectp->idleUpdate(agent, world, frame_time); } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 214db03994..6f4dff5819 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -64,7 +64,6 @@ #include "llvlmanager.h" #include "llvlcomposition.h" #include "llvocache.h" -#include "llvoclouds.h" #include "llworld.h" #include "llspatialpartition.h" #include "stringize.h" @@ -314,7 +313,6 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mImpl->mObjectPartition.push_back(new LLWaterPartition()); //PARTITION_WATER mImpl->mObjectPartition.push_back(new LLTreePartition()); //PARTITION_TREE mImpl->mObjectPartition.push_back(new LLParticlePartition()); //PARTITION_PARTICLE - mImpl->mObjectPartition.push_back(new LLCloudPartition()); //PARTITION_CLOUD mImpl->mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS mImpl->mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME mImpl->mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 4bc487e4cb..c8e9085707 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -81,7 +81,6 @@ public: PARTITION_WATER, PARTITION_TREE, PARTITION_PARTICLE, - PARTITION_CLOUD, PARTITION_GRASS, PARTITION_VOLUME, PARTITION_BRIDGE, diff --git a/indra/newview/llvoclouds.cpp b/indra/newview/llvoclouds.cpp deleted file mode 100644 index 78aa6e6ab8..0000000000 --- a/indra/newview/llvoclouds.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/** - * @file llvoclouds.cpp - * @brief Implementation of LLVOClouds class which is a derivation fo LLViewerObject - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llvoclouds.h" - -#include "lldrawpoolalpha.h" - -#include "llviewercontrol.h" - -#include "llagent.h" // to get camera position -#include "lldrawable.h" -#include "llface.h" -#include "llprimitive.h" -#include "llsky.h" -#include "llviewercamera.h" -#include "llviewertexturelist.h" -#include "llviewerobjectlist.h" -#include "llviewerregion.h" -#include "llvosky.h" -#include "llworld.h" -#include "pipeline.h" -#include "llspatialpartition.h" - -LLUUID gCloudTextureID = IMG_CLOUD_POOF; - - -LLVOClouds::LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) -: LLAlphaObject(id, LL_VO_CLOUDS, regionp) -{ - mCloudGroupp = NULL; - mbCanSelect = FALSE; - setNumTEs(1); - LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(gCloudTextureID); - image->setBoostLevel(LLViewerTexture::BOOST_CLOUDS); - setTEImage(0, image); -} - - -LLVOClouds::~LLVOClouds() -{ -} - - -BOOL LLVOClouds::isActive() const -{ - return TRUE; -} - -BOOL LLVOClouds::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) -{ - static LLFastTimer::DeclareTimer ftm("Idle Clouds"); - LLFastTimer t(ftm); - - if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS))) - { - return TRUE; - } - - // Set dirty flag (so renderer will rebuild primitive) - if (mDrawable) - { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); - } - - return TRUE; -} - - -void LLVOClouds::setPixelAreaAndAngle(LLAgent &agent) -{ - mAppAngle = 50; - mPixelArea = 1500*100; -} - -void LLVOClouds::updateTextures() -{ - getTEImage(0)->addTextureStats(mPixelArea); -} - -LLDrawable* LLVOClouds::createDrawable(LLPipeline *pipeline) -{ - pipeline->allocDrawable(this); - mDrawable->setLit(FALSE); - mDrawable->setRenderType(LLPipeline::RENDER_TYPE_CLOUDS); - - return mDrawable; -} - -static LLFastTimer::DeclareTimer FTM_UPDATE_CLOUDS("Update Clouds"); - -BOOL LLVOClouds::updateGeometry(LLDrawable *drawable) -{ - LLFastTimer ftm(FTM_UPDATE_CLOUDS); - if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS))) - { - return TRUE; - } - - if (drawable->isVisible()) - { - dirtySpatialGroup(TRUE); - } - - LLFace *facep; - - S32 num_faces = mCloudGroupp->getNumPuffs(); - - if (num_faces > drawable->getNumFaces()) - { - drawable->setNumFacesFast(num_faces, NULL, getTEImage(0)); - } - - mDepth = (getPositionAgent()-LLViewerCamera::getInstance()->getOrigin())*LLViewerCamera::getInstance()->getAtAxis(); - - S32 face_indx = 0; - for ( ; face_indx < num_faces; face_indx++) - { - facep = drawable->getFace(face_indx); - if (!facep) - { - llwarns << "No facep for index " << face_indx << llendl; - continue; - } - - facep->setSize(4, 6); - - facep->setTEOffset(face_indx); - facep->setTexture(getTEImage(0)); - const LLCloudPuff &puff = mCloudGroupp->getPuff(face_indx); - const LLVector3 puff_pos_agent = gAgent.getPosAgentFromGlobal(puff.getPositionGlobal()); - facep->mCenterLocal = puff_pos_agent; - /// Update cloud color based on sun color. - LLColor4 float_color(LLColor3(gSky.getSunDiffuseColor() + gSky.getSunAmbientColor()),puff.getAlpha()); - facep->setFaceColor(float_color); - } - for ( ; face_indx < drawable->getNumFaces(); face_indx++) - { - facep = drawable->getFace(face_indx); - if (!facep) - { - llwarns << "No facep for index " << face_indx << llendl; - continue; - } - - facep->setTEOffset(face_indx); - facep->setSize(0,0); - } - - drawable->movePartition(); - - return TRUE; -} - -F32 LLVOClouds::getPartSize(S32 idx) -{ - return (CLOUD_PUFF_HEIGHT+CLOUD_PUFF_WIDTH)*0.5f; -} - -void LLVOClouds::getGeometry(S32 te, - LLStrider& verticesp, - LLStrider& normalsp, - LLStrider& texcoordsp, - LLStrider& colorsp, - LLStrider& indicesp) -{ - - if (te >= mCloudGroupp->getNumPuffs()) - { - return; - } - - LLDrawable* drawable = mDrawable; - LLFace *facep = drawable->getFace(te); - - if (!facep->hasGeometry()) - { - return; - } - - LLVector3 normal(0.f,0.f,-1.f); - - const LLCloudPuff &puff = mCloudGroupp->getPuff(te); - S32 index_offset = facep->getGeomIndex(); - LLColor4 float_color(LLColor3(gSky.getSunDiffuseColor() + gSky.getSunAmbientColor()),puff.getAlpha()); - LLColor4U color; - color.setVec(float_color); - facep->setFaceColor(float_color); - - - LLVector3 up; - LLVector3 right; - LLVector3 at; - - const LLVector3& puff_pos_agent = facep->mCenterLocal; - LLVector2 uvs[4]; - - uvs[0].setVec(0.f, 1.f); - uvs[1].setVec(0.f, 0.f); - uvs[2].setVec(1.f, 1.f); - uvs[3].setVec(1.f, 0.f); - - LLVector3 vtx[4]; - - at = LLViewerCamera::getInstance()->getAtAxis(); - right = at % LLVector3(0.f, 0.f, 1.f); - right.normVec(); - up = right % at; - up.normVec(); - right *= 0.5f*CLOUD_PUFF_WIDTH; - up *= 0.5f*CLOUD_PUFF_HEIGHT;; - - *colorsp++ = color; - *colorsp++ = color; - *colorsp++ = color; - *colorsp++ = color; - - vtx[0] = puff_pos_agent - right + up; - vtx[1] = puff_pos_agent - right - up; - vtx[2] = puff_pos_agent + right + up; - vtx[3] = puff_pos_agent + right - up; - - *verticesp++ = vtx[0]; - *verticesp++ = vtx[1]; - *verticesp++ = vtx[2]; - *verticesp++ = vtx[3]; - - *texcoordsp++ = uvs[0]; - *texcoordsp++ = uvs[1]; - *texcoordsp++ = uvs[2]; - *texcoordsp++ = uvs[3]; - - *normalsp++ = normal; - *normalsp++ = normal; - *normalsp++ = normal; - *normalsp++ = normal; - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 3; - *indicesp++ = index_offset + 2; -} - -U32 LLVOClouds::getPartitionType() const -{ - return LLViewerRegion::PARTITION_CLOUD; -} - -// virtual -void LLVOClouds::updateDrawable(BOOL force_damped) -{ - // Force an immediate rebuild on any update - if (mDrawable.notNull()) - { - mDrawable->updateXform(TRUE); - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); - } - clearChanged(SHIFTED); -} - -LLCloudPartition::LLCloudPartition() -{ - mDrawableType = LLPipeline::RENDER_TYPE_CLOUDS; - mPartitionType = LLViewerRegion::PARTITION_CLOUD; -} - diff --git a/indra/newview/llvoclouds.h b/indra/newview/llvoclouds.h deleted file mode 100644 index 430923a108..0000000000 --- a/indra/newview/llvoclouds.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file llvoclouds.h - * @brief Description of LLVOClouds class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLVOCLOUDS_H -#define LL_LLVOCLOUDS_H - -#include "llviewerobject.h" -#include "lltable.h" -#include "v4coloru.h" - -class LLViewerTexture; -class LLViewerCloudGroup; - -class LLCloudGroup; - - -class LLVOClouds : public LLAlphaObject -{ -public: - LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp ); - - // Initialize data that's only inited once per class. - static void initClass(); - - void updateDrawable(BOOL force_damped); - - /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); - /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); - /*virtual*/ void getGeometry(S32 te, - LLStrider& verticesp, - LLStrider& normalsp, - LLStrider& texcoordsp, - LLStrider& colorsp, - LLStrider& indicesp); - - /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. - F32 getPartSize(S32 idx); - - /*virtual*/ void updateTextures(); - /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area - - void updateFaceSize(S32 idx) { } - BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); - - virtual U32 getPartitionType() const; - - void setCloudGroup(LLCloudGroup *cgp) { mCloudGroupp = cgp; } -protected: - virtual ~LLVOClouds(); - - LLCloudGroup *mCloudGroupp; -}; - -extern LLUUID gCloudTextureID; - -#endif // LL_VO_CLOUDS_H diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 596ab5931c..c42d13db35 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -61,7 +61,6 @@ #include #include -#define TMP_WL_REMOVE_CLOUDS /* disables code for classic clouds */ // // Globals @@ -94,10 +93,6 @@ LLWorld::LLWorld() : mLastPacketsOut(0), mLastPacketsLost(0), mSpaceTimeUSec(0) -#ifndef TMP_WL_REMOVE_CLOUDS - , - mClassicCloudsEnabled(FALSE) -#endif { for (S32 i = 0; i < 8; i++) { @@ -188,12 +183,6 @@ LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host) llerrs << "Unable to create new region!" << llendl; } -#ifndef TMP_WL_REMOVE_CLOUDS - regionp->mCloudLayer.create(regionp); - regionp->mCloudLayer.setWidth((F32)mWidth); - regionp->mCloudLayer.setWindPointer(®ionp->mWind); -#endif // TMP_WL_REMOVE_CLOUDS - mRegionList.push_back(regionp); mActiveRegionList.push_back(regionp); mCulledRegionList.push_back(regionp); @@ -668,65 +657,6 @@ void LLWorld::updateParticles() LLViewerPartSim::getInstance()->updateSimulation(); } -#ifndef TMP_WL_REMOVE_CLOUDS -void LLWorld::updateClouds(const F32 dt) -{ - static LLFastTimer::DeclareTimer ftm("World Clouds"); - LLFastTimer t(ftm); - - if ( gSavedSettings.getBOOL("FreezeTime") ) - { - // don't move clouds in snapshot mode - return; - } - - if (mActiveRegionList.size()) - { - for (region_list_t::iterator iter = mActiveRegionList.begin(); - iter != mActiveRegionList.end(); ++iter) - { - LLViewerRegion* regionp = *iter; - regionp->mCloudLayer.updatePuffs(dt); - } - - // Reshuffle who owns which puffs - for (region_list_t::iterator iter = mActiveRegionList.begin(); - iter != mActiveRegionList.end(); ++iter) - { - LLViewerRegion* regionp = *iter; - regionp->mCloudLayer.updatePuffOwnership(); - } - - // Add new puffs - for (region_list_t::iterator iter = mActiveRegionList.begin(); - iter != mActiveRegionList.end(); ++iter) - { - LLViewerRegion* regionp = *iter; - regionp->mCloudLayer.updatePuffCount(); - } - } -} - -LLCloudGroup* LLWorld::findCloudGroup(const LLCloudPuff &puff) -{ - if (mActiveRegionList.size()) - { - // Update all the cloud puff positions, and timer based stuff - // such as death decay - for (region_list_t::iterator iter = mActiveRegionList.begin(); - iter != mActiveRegionList.end(); ++iter) - { - LLViewerRegion* regionp = *iter; - LLCloudGroup *groupp = regionp->mCloudLayer.findCloudGroup(puff); - if (groupp) - { - return groupp; - } - } - } - return NULL; -} -#endif // TMP_WL_REMOVE_CLOUDS void LLWorld::renderPropertyLines() { -- cgit v1.2.3 From c0037909d576fc4922b92dfcc83d865d61ac43cb Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 19:32:20 +0300 Subject: STORM-1284 FIXED Changes to region environment are now visible immediately. Pressing "Apply" sends the settings update to server. Pressing "Cancel" reverts to current region settings. --- indra/newview/llenvmanager.cpp | 78 ++++++- indra/newview/llenvmanager.h | 9 + indra/newview/llfloaterregioninfo.cpp | 242 +++++++++++++++------ indra/newview/llfloaterregioninfo.h | 13 +- indra/newview/llwlparammanager.cpp | 68 +++--- indra/newview/llwlparammanager.h | 10 +- .../default/xui/en/panel_region_environment.xml | 4 +- 7 files changed, 330 insertions(+), 94 deletions(-) (limited to 'indra') diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index f12c3e54ff..d5d03ff1e5 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -37,6 +37,7 @@ #include "llagent.h" #include "llviewerregion.h" +#include "lldaycyclemanager.h" #include "llfloaterreg.h" #include "llfloaterwindlight.h" #include "llfloaterwater.h" @@ -668,6 +669,74 @@ const LLEnvironmentSettings& LLEnvManagerNew::getRegionSettings() const return mCachedRegionPrefs; } +bool LLEnvManagerNew::usePrefs() +{ + LL_DEBUGS("Windlight") << "Displaying preferred environment" << LL_ENDL; + updateManagersFromPrefs(false); + return true; +} + +bool LLEnvManagerNew::useDefaults() +{ + bool rslt = useWaterPreset("Default") && useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); + return rslt; +} + +bool LLEnvManagerNew::useWaterPreset(const std::string& name) +{ + LL_DEBUGS("Windlight") << "Displaying water preset " << name << LL_ENDL; + LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); + bool rslt = water_mgr.getParamSet(name, water_mgr.mCurParams); + llassert(rslt == true); + return rslt; +} + +bool LLEnvManagerNew::useWaterParams(const LLSD& params) +{ + LL_DEBUGS("Windlight") << "Displaying water params" << LL_ENDL; + LLWaterParamManager::instance().mCurParams.setAll(params); + return true; +} + +bool LLEnvManagerNew::useSkyParams(const LLSD& params) +{ + LL_DEBUGS("Windlight") << "Displaying sky params" << LL_ENDL; + LLWLParamManager::instance().applySkyParams(params); + return true; +} + +bool LLEnvManagerNew::useDayCycle(const std::string& name, LLEnvKey::EScope scope) +{ + LLSD params; + + if (scope == LLEnvKey::SCOPE_REGION) + { + LL_DEBUGS("Windlight") << "Displaying region day cycle " << name << LL_ENDL; + params = getRegionSettings().getWLDayCycle(); + } + else + { + LL_DEBUGS("Windlight") << "Displaying local day cycle " << name << LL_ENDL; + + if (!LLDayCycleManager::instance().getPreset(name, params)) + { + llwarns << "No day cycle named " << name << llendl; + return false; + } + } + + bool rslt = LLWLParamManager::instance().applyDayCycleParams(params, scope); + llassert(rslt == true); + return rslt; +} + +bool LLEnvManagerNew::useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope) +{ + LL_DEBUGS("Windlight") << "Displaying day cycle params" << LL_ENDL; + LLWLParamManager::instance().applyDayCycleParams(params, scope); + return true; +} + void LLEnvManagerNew::setUseRegionSettings(bool val) { mUserPrefs.setUseDefaults(val); @@ -818,9 +887,14 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); mCachedRegionPrefs = new_settings; + // Load region sky presets. + LLWLParamManager::instance().refreshRegionPresets(); + // If using server settings, update managers. - // This also adds server skies to the WL param mgr. - updateManagersFromPrefs(mInterpNextChangeMessage); + if (getUseRegionSettings()) + { + updateManagersFromPrefs(mInterpNextChangeMessage); + } // Let interested parties know about the region settings update. mRegionSettingsChangeSignal(); diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 223654151b..21b771bed8 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -276,6 +276,15 @@ public: /// @return cached env. settings of the current region. const LLEnvironmentSettings& getRegionSettings() const; + // Change environment w/o changing user preferences. + bool usePrefs(); + bool useDefaults(); + bool useWaterPreset(const std::string& name); + bool useWaterParams(const LLSD& params); + bool useSkyParams(const LLSD& params); + bool useDayCycle(const std::string& name, LLEnvKey::EScope scope); + bool useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope); + // setters for user env. preferences void setUseRegionSettings(bool val); void setUseWaterPreset(const std::string& name); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 6a5b577396..ee3d00206f 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1124,7 +1124,7 @@ F32 LLPanelRegionTerrainInfo::getSunHour() // virtual bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) { - LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); + //LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); @@ -2088,7 +2088,7 @@ void LLFloaterRegionInfo::onClose(bool app_quitting) { if(!app_quitting) { - LLEnvManager::getInstance()->maybeClearEditingScope(true, false); + //LLEnvManager::getInstance()->maybeClearEditingScope(true, false); LLPanelRegionTerrainInfo::onFloaterClose(app_quitting); } } @@ -3198,10 +3198,15 @@ BOOL LLPanelEnvironmentInfo::postBuild() mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); mWaterPresetCombo = getChild("water_settings_preset_combo"); + mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); + mSkyPresetCombo = getChild("sky_settings_preset_combo"); + mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); + mDayCyclePresetCombo = getChild("dayc_settings_preset_combo"); + mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - childSetCommitCallback("save_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnSave, this), NULL); + childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); @@ -3217,6 +3222,17 @@ void LLPanelEnvironmentInfo::onOpen(const LLSD& key) refresh(); } +// virtual +void LLPanelEnvironmentInfo::handleVisibilityChange(BOOL new_visibility) +{ + // If hiding (user switched to another tab or closed the floater), + // display user's preferred environment. + if (!new_visibility) + { + LLEnvManagerNew::instance().usePrefs(); + } +} + // virtual bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) { @@ -3257,14 +3273,18 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) mSkyPresetCombo->setEnabled(enabled); mDayCyclePresetCombo->setEnabled(enabled); - getChildView("save_btn")->setEnabled(enabled); + getChildView("apply_btn")->setEnabled(enabled); getChildView("cancel_btn")->setEnabled(enabled); if (enabled) { // Enable/disable some controls based on currently selected radio buttons. - LLPanelEnvironmentInfo::onSwitchRegionSettings(); - LLPanelEnvironmentInfo::onSwitchDayCycle(); + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild("user_environment_settings")->setEnabled(!use_defaults); + + bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + mSkyPresetCombo->setEnabled(is_fixed_sky); + mDayCyclePresetCombo->setEnabled(!is_fixed_sky); } } @@ -3367,9 +3387,97 @@ void LLPanelEnvironmentInfo::populateDayCyclesList() // Current day cycle is already selected. } +bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) +{ + LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); + + if (water_key.scope == LLEnvKey::SCOPE_REGION) + { + water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); + } + else + { + LLWaterParamSet param_set; + if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) + { + llwarns << "Error getting water preset: " << water_key.name << llendl; + return false; + } + + water_params = param_set.getAll(); + } + + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) +{ + std::string preset_key(mSkyPresetCombo->getValue().asString()); + LLWLParamKey preset(preset_key); + + // Get the preset sky params. + LLWLParamSet param_set; + if (!LLWLParamManager::instance().getParamSet(preset, param_set)) + { + llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; + return false; + } + + sky_params = param_set.getAll(); + preset_name = preset.name; + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) +{ + std::string preset_key(mDayCyclePresetCombo->getValue().asString()); + LLWLParamKey dc(preset_key); + LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; + + if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle + { + const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); + day_cycle = cur_region_settings.getWLDayCycle(); + sky_map = cur_region_settings.getSkyMap(); + } + else // a local day cycle + { + if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) + { + llwarns << "Error getting day cycle " << dc.name << llendl; + return false; + } + + // Create sky map from the day cycle. + { + std::map refs; + LLWLDayCycle tmp_day; + + tmp_day.loadDayCycle(day_cycle, dc.scope); + tmp_day.getSkyRefs(refs); + + sky_map = LLWLParamManager::createSkyMap(refs); + } + } + + scope = dc.scope; + + return true; +} void LLPanelEnvironmentInfo::onSwitchRegionSettings() { - getChild("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild("user_environment_settings")->setEnabled(!use_defaults); + + if (use_defaults) + { + LLEnvManagerNew::instance().useDefaults(); + } + else + { + onSelectWaterPreset(); + onSwitchDayCycle(); + } } void LLPanelEnvironmentInfo::onSwitchDayCycle() @@ -3378,13 +3486,52 @@ void LLPanelEnvironmentInfo::onSwitchDayCycle() mSkyPresetCombo->setEnabled(is_fixed_sky); mDayCyclePresetCombo->setEnabled(!is_fixed_sky); + + if (is_fixed_sky) + { + onSelectSkyPreset(); + } + else + { + onSelectDayCycle(); + } +} + +void LLPanelEnvironmentInfo::onSelectWaterPreset() +{ + LLSD water_params; + + if (getSelectedWaterParams(water_params)) + { + LLEnvManagerNew::instance().useWaterParams(water_params); + } } -void LLPanelEnvironmentInfo::onBtnSave() +void LLPanelEnvironmentInfo::onSelectSkyPreset() { - LL_DEBUGS("Windlight") << "About to save region settings" << LL_ENDL; + LLSD params; + std::string dummy; + + if (getSelectedSkyParams(params, dummy)) + { + LLEnvManagerNew::instance().useSkyParams(params); + } +} + +void LLPanelEnvironmentInfo::onSelectDayCycle() +{ + LLSD day_cycle; + LLSD sky_map; // unused + short scope; - const LLEnvironmentSettings& old_region_settings = LLEnvManagerNew::instance().getRegionSettings(); + if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) + { + LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); + } +} + +void LLPanelEnvironmentInfo::onBtnApply() +{ const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; @@ -3402,79 +3549,44 @@ void LLPanelEnvironmentInfo::onBtnSave() if (use_fixed_sky) { LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; - std::string preset_key(mSkyPresetCombo->getValue().asString()); - LLWLParamKey preset(preset_key); - // Get the preset sky params. - LLWLParamSet params; - if (!LLWLParamManager::instance().getParamSet(preset, params)) + // Get selected sky params. + LLSD params; + std::string preset_name; + if (!getSelectedSkyParams(params, preset_name)) { - llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; return; } // Create a day cycle consisting of a single sky preset. LLSD key(LLSD::emptyArray()); key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle - key.append(preset.name); + key.append(preset_name); day_cycle.append(key); // Create a sky map consisting of only the sky preset. std::map refs; - refs[preset] = params; + LLWLParamSet param_set; + param_set.setAll(params); + refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here sky_map = LLWLParamManager::createSkyMap(refs); } else // use day cycle { - std::string preset_key(mDayCyclePresetCombo->getValue().asString()); - LLWLParamKey dc(preset_key); - LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; + LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; - if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle - { - day_cycle = old_region_settings.getWLDayCycle(); - sky_map = old_region_settings.getSkyMap(); - } - else // a local day cycle + short scope; // unused + if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) { - if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) - { - llwarns << "Error getting day cycle " << dc.name << llendl; - return; - } - - // Create sky map from the day cycle. - { - std::map refs; - LLWLDayCycle tmp_day; - - tmp_day.loadDayCycle(day_cycle, dc.scope); - tmp_day.getSkyRefs(refs); - - sky_map = LLWLParamManager::createSkyMap(refs); - } - - LL_DEBUGS("Windlight") << "day_cycle: " << day_cycle << LL_ENDL; - LL_DEBUGS("Windlight") << "sky_map: " << sky_map << LL_ENDL; + return; } } // Get water params. - LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); - if (water_key.scope == LLEnvKey::SCOPE_REGION) - { - water_params = old_region_settings.getWaterParams(); - } - else + if (!getSelectedWaterParams(water_params)) { - LLWaterParamSet param_set; - if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) - { - llwarns << "Error getting water preset: " << water_key.name << llendl; - return; - } - - water_params = param_set.getAll(); + // *TODO: show a notification? + return; } } @@ -3492,8 +3604,16 @@ void LLPanelEnvironmentInfo::onBtnSave() void LLPanelEnvironmentInfo::onBtnCancel() { - // Reload current region settings. + // Reload last saved region settings. refresh(); + + // Apply them. + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); + const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); + const LLSD& region_water = cur_settings.getWaterParams(); + env_mgr.useWaterParams(region_water); + env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); } void LLPanelEnvironmentInfo::onRegionSettingschange() diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index d96ab1339f..713afae1f6 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -433,6 +433,9 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + // LLView + /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + // LLPanelRegionInfo /*virtual*/ bool refreshFromRegion(LLViewerRegion* region); @@ -445,10 +448,18 @@ private: void populateSkyPresetsList(); void populateDayCyclesList(); + bool getSelectedWaterParams(LLSD& water_params); + bool getSelectedSkyParams(LLSD& sky_params, std::string& preset_name); + bool getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope); + void onSwitchRegionSettings(); void onSwitchDayCycle(); - void onBtnSave(); + void onSelectWaterPreset(); + void onSelectSkyPreset(); + void onSelectDayCycle(); + + void onBtnApply(); void onBtnCancel(); void onRegionSettingschange(); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 396c61b4b6..3dad7b2f4e 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -256,6 +256,15 @@ void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& } } +void LLWLParamManager::refreshRegionPresets() +{ + // Remove all region sky presets because they may belong to a previously visited region. + clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + + // Add all sky presets belonging to the current region. + addAllSkies(LLEnvKey::SCOPE_REGION, LLEnvManagerNew::instance().getRegionSettings().getSkyMap()); +} + void LLWLParamManager::loadPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); @@ -587,16 +596,11 @@ void LLWLParamManager::update(LLViewerCamera * cam) void LLWLParamManager::applyUserPrefs(bool interpolate) { - // Remove all region sky presets because they may belong to a previously visited region. - clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - // Add all sky presets belonging to the current region. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); - - if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings + if (env_mgr.getUseRegionSettings()) // apply region-wide settings { - if (region_settings.getSkyMap().size() == 0) + if (env_mgr.getRegionSettings().getSkyMap().size() == 0) { applyDefaults(); } @@ -606,15 +610,18 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; // Apply region day cycle. - mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); - resetAnimator(region_settings.getDayTime(), true); + const LLEnvironmentSettings& region_settings = env_mgr.getRegionSettings(); + applyDayCycleParams( + region_settings.getWLDayCycle(), + LLEnvKey::SCOPE_REGION, + region_settings.getDayTime()); } } else // apply user-specified settings { - if (LLEnvManagerNew::instance().getUseDayCycle()) + if (env_mgr.getUseDayCycle()) { - if (!applyDayCycle(LLEnvManagerNew::instance().getDayCycleName())) + if (!env_mgr.useDayCycle(env_mgr.getDayCycleName(), LLEnvKey::SCOPE_LOCAL)); { // *TODO: fix user prefs applyDefaults(); @@ -622,30 +629,39 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) } else { - mAnimator.deactivate(); - std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); - LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; - getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); + LLWLParamSet param_set; + std::string sky = env_mgr.getSkyPresetName(); + + if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), param_set)) + { + llwarns << "No sky named " << sky << llendl; + } + else + { + LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; + applySkyParams(param_set.getAll()); + } } } } void LLWLParamManager::applyDefaults() { - llassert(applyDayCycle("Default") == true); + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + llassert(env_mgr.useDayCycle("Default", LLEnvKey::SCOPE_LOCAL) == true); } -bool LLWLParamManager::applyDayCycle(const std::string& day_cycle) +bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) { - LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - - if (!LLDayCycleManager::instance().getPreset(day_cycle, mDay)) - { - llwarns << "No day cycle named " << day_cycle << llendl; - return false; - } + mDay.loadDayCycle(params, scope); + resetAnimator(time, true); // set to specified time and start animator + return true; +} - resetAnimator(0.5, true); // set to noon and start animator +bool LLWLParamManager::applySkyParams(const LLSD& params) +{ + mAnimator.deactivate(); + mCurParams.setAll(params); return true; } diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index eb810a4086..7903661a7e 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -245,8 +245,11 @@ public: /// apply default sky params void applyDefaults(); - /// apply default sky params - bool applyDayCycle(const std::string& day); + /// apply specified day cycle, setting time to noon by default + bool applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time = 0.5); + + /// apply specified fixed sky params + bool applySkyParams(const LLSD& params); // get where the light is pointing inline LLVector4 getLightDir(void) const; @@ -288,6 +291,9 @@ public: /// add all skies in LLSD using the given scope void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map); + /// refresh region-scope presets + void refreshRegionPresets(); + // returns all skies referenced by the current day cycle (in mDay), with their final names // side effect: applies changes to all internal structures! (trashes all unreferenced skies in scope, keys in day cycle rescoped to scope, etc.) std::map finalizeFromDayCycle(LLWLParamKey::EScope scope); diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml index 956ba53a26..91d0bbe6bf 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -123,10 +123,10 @@ -- cgit v1.2.3 From 0d246c0c5fc3ddef2022572b560eaec0018a722e Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 16 Jun 2011 17:14:51 -0700 Subject: EXP-872 PROGRESS -- Hide Inbox unless applicable EXP-910 FIX -- Newness badge shown on suitcase inventory icon when InventoryDisplayInbox is set to False EXP-895 FIX -- Selecting items in Marketplace Inbox does not change focus in inventory panel away from items selected in inventory panel * Main inventory, outbox and inbox all clear the selection of the others when they gain focus * The Fresh Item Count badge is no longer displayed on the inventory side tab button when the inbox is disabled * The New Item Count text is no longer displayed. (we will enable it again when freshness is supported) --- indra/newview/llpanelmaininventory.cpp | 20 ++++++++++++++++ indra/newview/llpanelmaininventory.h | 2 ++ indra/newview/llpanelmarketplaceinbox.cpp | 38 ++++++++++++++++++++++++++++-- indra/newview/llpanelmarketplaceinbox.h | 2 ++ indra/newview/llpanelmarketplaceoutbox.cpp | 28 ++++++++++++++++++++++ indra/newview/llpanelmarketplaceoutbox.h | 2 ++ indra/newview/llsidepanelinventory.cpp | 37 ++++++++++++++++++++--------- indra/newview/llsidepanelinventory.h | 8 ++++++- 8 files changed, 123 insertions(+), 14 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index bc4998dd0c..9f797eb147 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -193,6 +193,9 @@ BOOL LLPanelMainInventory::postBuild() mMenuAdd->getChild("Upload Animation")->setLabelArg("[COST]", upload_cost); mMenuAdd->getChild("Bulk Upload")->setLabelArg("[COST]", upload_cost); + // Trigger callback for focus received so we can deselect items in inbox/outbox + LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMainInventory::onFocusReceived, this)); + return TRUE; } @@ -572,6 +575,23 @@ void LLPanelMainInventory::updateItemcountText() getChild("ItemcountText")->setValue(text); } +void LLPanelMainInventory::onFocusReceived() +{ + LLInventoryPanel * inbox_panel = findChild("inventory_inbox"); + + if (inbox_panel) + { + inbox_panel->clearSelection(); + } + + LLInventoryPanel * outbox_panel = findChild("inventory_outbox"); + + if (outbox_panel) + { + outbox_panel->clearSelection(); + } +} + void LLPanelMainInventory::setFilterTextFromFilter() { mFilterText = mActivePanel->getFilter()->getFilterText(); diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index 2b2ee1c0c9..86b2c87e0b 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -114,6 +114,8 @@ protected: bool isSaveTextureEnabled(const LLSD& userdata); void updateItemcountText(); + void onFocusReceived(); + private: LLFloaterInventoryFinder* getFinder(); diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index 0fe2560fbf..eff27aa541 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -31,6 +31,11 @@ #include "llappviewer.h" #include "llbutton.h" #include "llinventorypanel.h" +#include "llsidepanelinventory.h" + + +#define SUPPORTING_FRESH_ITEM_COUNT 0 + static LLRegisterPanelClassWrapper t_panel_marketplace_inbox("panel_marketplace_inbox"); @@ -59,6 +64,8 @@ BOOL LLPanelMarketplaceInbox::postBuild() LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceInbox::handleLoginComplete, this)); + LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceInbox::onFocusReceived, this)); + return TRUE; } @@ -68,6 +75,28 @@ void LLPanelMarketplaceInbox::handleLoginComplete() LLSideTray::getInstance()->setTabButtonBadgeDriver("sidebar_inventory", this); } +void LLPanelMarketplaceInbox::onFocusReceived() +{ + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + + if (sidepanel_inventory) + { + LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel(); + + if (inv_panel) + { + inv_panel->clearSelection(); + } + + LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); + + if (outbox_panel) + { + outbox_panel->clearSelection(); + } + } +} + BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { *accept = ACCEPT_NO; @@ -126,8 +155,9 @@ std::string LLPanelMarketplaceInbox::getBadgeString() const { std::string item_count_str(""); - // If side panel collapsed or expanded and not inventory - if (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory")) + // If the inbox is visible, and the side panel is collapsed or expanded and not the inventory panel + if (getParent()->getVisible() && + (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory"))) { U32 item_count = getFreshItemCount(); @@ -154,6 +184,7 @@ void LLPanelMarketplaceInbox::draw() args["[NUM]"] = item_count_str; getChild("inbox_btn")->setLabel(getString("InboxLabelWithArg", args)); +#if SUPPORTING_FRESH_ITEM_COUNT // set green text to fresh item count U32 fresh_item_count = getFreshItemCount(); fresh_new_count_view->setVisible((fresh_item_count > 0)); @@ -162,6 +193,9 @@ void LLPanelMarketplaceInbox::draw() { getChild("inbox_fresh_new_count")->setTextArg("[NUM]", llformat("%d", fresh_item_count)); } +#else + fresh_new_count_view->setVisible(FALSE); +#endif } else { diff --git a/indra/newview/llpanelmarketplaceinbox.h b/indra/newview/llpanelmarketplaceinbox.h index 21069a0ea1..d5b216b56d 100644 --- a/indra/newview/llpanelmarketplaceinbox.h +++ b/indra/newview/llpanelmarketplaceinbox.h @@ -63,6 +63,8 @@ public: private: void handleLoginComplete(); + void onFocusReceived(); + private: LLInventoryPanel* mInventoryPanel; }; diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 96695becf0..c8752b3e0f 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -31,7 +31,11 @@ #include "llbutton.h" #include "llcoros.h" #include "lleventcoro.h" +#include "llinventorypanel.h" #include "llloadingindicator.h" +#include "llpanelmarketplaceinbox.h" +#include "llsidepanelinventory.h" +#include "llsidetray.h" #include "lltimer.h" @@ -60,9 +64,33 @@ BOOL LLPanelMarketplaceOutbox::postBuild() mSyncButton->setEnabled(!isOutboxEmpty()); + LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceOutbox::onFocusReceived, this)); + return TRUE; } +void LLPanelMarketplaceOutbox::onFocusReceived() +{ + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + + if (sidepanel_inventory) + { + LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel(); + + if (inv_panel) + { + inv_panel->clearSelection(); + } + + LLInventoryPanel * inbox_panel = sidepanel_inventory->findChild("inventory_inbox"); + + if (inbox_panel) + { + inbox_panel->clearSelection(); + } + } +} + bool LLPanelMarketplaceOutbox::isOutboxEmpty() const { // TODO: Check for contents of outbox diff --git a/indra/newview/llpanelmarketplaceoutbox.h b/indra/newview/llpanelmarketplaceoutbox.h index 2fbe819762..94bc066224 100644 --- a/indra/newview/llpanelmarketplaceoutbox.h +++ b/indra/newview/llpanelmarketplaceoutbox.h @@ -54,6 +54,8 @@ protected: void onSyncButtonClicked(); void updateSyncButtonStatus(); + void onFocusReceived(); + private: LLButton * mSyncButton; LLLoadingIndicator * mSyncIndicator; diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index d916c430a8..32394da042 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -32,10 +32,10 @@ #include "llappviewer.h" #include "llavataractions.h" #include "llbutton.h" -#include "llcurl.h" #include "lldate.h" #include "llfirstuse.h" #include "llfoldertype.h" +#include "llhttpclient.h" #include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" @@ -69,6 +69,9 @@ static const char * const INBOX_LAYOUT_PANEL_NAME = "inbox_layout_panel"; static const char * const OUTBOX_LAYOUT_PANEL_NAME = "outbox_layout_panel"; static const char * const MAIN_INVENTORY_LAYOUT_PANEL = "main_inventory_layout_panel"; +static const char * const INBOX_INVENTORY_PANEL = "inventory_inbox"; +static const char * const OUTBOX_INVENTORY_PANEL = "inventory_outbox"; + static const char * const INVENTORY_LAYOUT_STACK_NAME = "inventory_layout_stack"; // @@ -84,14 +87,23 @@ public: { } - void errorWithContent(U32 status, const std::string& reason, const LLSD& content) + void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "Marketplace Inbox Disabled" << llendl; - } - - void result(const LLSD& content) - { - mSidepanelInventory->enableInbox(true); + if (isGoodStatus(status)) + { + // Complete success + mSidepanelInventory->enableInbox(true); + } + else if (status == 401) + { + // API is available for use but OpenID authorization failed + mSidepanelInventory->enableInbox(true); + } + else + { + // API in unavailable + llinfos << "Marketplace API is unavailable -- Inbox Disabled" << llendl; + } } private: @@ -106,7 +118,8 @@ LLSidepanelInventory::LLSidepanelInventory() : LLPanel() , mItemPanel(NULL) , mPanelMainInventory(NULL) - , mInventoryFetched(false) + , mInboxEnabled(false) + , mOutboxEnabled(false) , mCategoriesObserver(NULL) { //buildFromFile( "panel_inventory.xml"); // Called from LLRegisterPanelClass::defaultPanelClassBuilder() @@ -205,8 +218,8 @@ BOOL LLSidepanelInventory::postBuild() outbox_button->setCommitCallback(boost::bind(&LLSidepanelInventory::onToggleOutboxBtn, this)); // Set the inbox and outbox visible based on debug settings (final setting comes from http request below) - inbox_panel->setVisible(gSavedSettings.getBOOL("InventoryDisplayInbox")); - outbox_panel->setVisible(gSavedSettings.getBOOL("InventoryDisplayOutbox")); + enableInbox(gSavedSettings.getBOOL("InventoryDisplayInbox")); + enableOutbox(gSavedSettings.getBOOL("InventoryDisplayOutbox")); // Trigger callback for after login so we can setup to track inbox and outbox changes after initial inventory load LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLSidepanelInventory::handleLoginComplete, this)); @@ -258,11 +271,13 @@ void LLSidepanelInventory::handleLoginComplete() void LLSidepanelInventory::enableInbox(bool enabled) { + mInboxEnabled = enabled; getChild(INBOX_LAYOUT_PANEL_NAME)->setVisible(enabled); } void LLSidepanelInventory::enableOutbox(bool enabled) { + mOutboxEnabled = enabled; getChild(OUTBOX_LAYOUT_PANEL_NAME)->setVisible(enabled); } diff --git a/indra/newview/llsidepanelinventory.h b/indra/newview/llsidepanelinventory.h index 25fc28d56b..b68abd65cc 100644 --- a/indra/newview/llsidepanelinventory.h +++ b/indra/newview/llsidepanelinventory.h @@ -43,8 +43,10 @@ public: LLSidepanelInventory(); virtual ~LLSidepanelInventory(); +private: void handleLoginComplete(); +public: /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); @@ -65,6 +67,9 @@ public: void enableInbox(bool enabled); void enableOutbox(bool enabled); + bool isInboxEnabled() const { return mInboxEnabled; } + bool isOutboxEnabled() const { return mOutboxEnabled; } + protected: // Tracks highlighted (selected) item in inventory panel. LLInventoryItem *getSelectedItem(); @@ -107,7 +112,8 @@ private: LLButton* mOverflowBtn; LLButton* mShopBtn; - bool mInventoryFetched; + bool mInboxEnabled; + bool mOutboxEnabled; LLInventoryCategoriesObserver* mCategoriesObserver; }; -- cgit v1.2.3 From 6215e6ba2542633afc5f8957817015f4bcf9f3cf Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 17 Jun 2011 13:22:13 -0700 Subject: EXP-872 PROGRESS -- Hide inbox unless applicable * Updated to use the current user's agent id instead of Pup's Reviewed by Leyla :) --- indra/newview/llsidepanelinventory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 32394da042..787ebd29c2 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -241,10 +241,12 @@ void LLSidepanelInventory::handleLoginComplete() std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); url = llformat("https://marketplace.%s.lindenlab.com/", utf8str_tolower(gridLabel).c_str()); } + + url += "api/1/users/"; + url += gAgent.getID().getString(); + url += "/user_status"; - std::string url_suffix = "api/1/users/b72d31f8-d03c-4a3b-a002-3dd7b4a712b8/user_status"; - - LLHTTPClient::get(url + url_suffix, new LLInventoryUserStatusResponder(this)); + LLHTTPClient::get(url, new LLInventoryUserStatusResponder(this)); // // Track inbox and outbox folder changes -- cgit v1.2.3 From 353da63a07b07b75ad73b9f5cb8e463d07ebea3a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 17 Jun 2011 15:24:24 -0700 Subject: EXP-915 FIX remove mHidden and mStartFolderID from LLFolderView* cleaned up and refactored inventory code a bit reviewed by Leyla --- indra/newview/llfolderview.cpp | 49 +++-- indra/newview/llfolderview.h | 9 +- indra/newview/llfolderviewitem.cpp | 119 +++++++++--- indra/newview/llfolderviewitem.h | 14 +- indra/newview/llinventoryfilter.cpp | 122 +++++------- indra/newview/llinventoryfilter.h | 6 +- indra/newview/llinventorypanel.cpp | 324 +++++++++++++++---------------- indra/newview/llinventorypanel.h | 19 +- indra/newview/llpanellandmarks.cpp | 4 +- indra/newview/llplacesinventorypanel.cpp | 85 +++----- indra/newview/lltexturectrl.cpp | 1 - 11 files changed, 370 insertions(+), 382 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 3884b94b60..260693ebc7 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -167,13 +167,22 @@ void LLCloseAllFoldersFunctor::doItem(LLFolderViewItem* item) ///---------------------------------------------------------------------------- /// Class LLFolderView ///---------------------------------------------------------------------------- +LLFolderView::Params::Params() +: task_id("task_id"), + title("title"), + use_label_suffix("use_label_suffix"), + allow_multiselect("allow_multiselect", true), + use_ellipses("use_ellipses", false) +{ +} + // Default constructor LLFolderView::LLFolderView(const Params& p) : LLFolderViewFolder(p), mScrollContainer( NULL ), mPopupMenuHandle(), - mAllowMultiSelect(TRUE), + mAllowMultiSelect(p.allow_multiselect), mShowFolderHierarchy(FALSE), mSourceID(p.task_id), mRenameItem( NULL ), @@ -194,10 +203,12 @@ LLFolderView::LLFolderView(const Params& p) mDragAndDropThisFrame(FALSE), mCallbackRegistrar(NULL), mParentPanel(p.parent_panel), - mUseEllipses(false), + mUseEllipses(p.use_ellipses), mDraggingOverItem(NULL), mStatusTextBox(NULL) { + mRoot = this; + LLRect rect = p.rect; LLRect new_rect(rect.mLeft, rect.mBottom + getRect().getHeight(), rect.mLeft + getRect().getWidth(), rect.mBottom); setRect( rect ); @@ -424,11 +435,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter } - // Need to call arrange regardless of visibility, since children's visibility - // might need to be changed too (e.g. even though a folder is invisible, its - // children also need to be set invisible for state-tracking purposes, e.g. - // llfolderviewitem::filter). - // if (folderp->getVisible()) + if (folderp->getVisible()) { S32 child_height = 0; S32 child_width = 0; @@ -764,7 +771,7 @@ void LLFolderView::sanitizeSelection() } // Don't allow invisible items (such as root folders) to be selected. - if (item->getHidden()) + if (item == getRoot()) { items_to_remove.push_back(item); } @@ -787,7 +794,7 @@ void LLFolderView::sanitizeSelection() parent_folder; parent_folder = parent_folder->getParentFolder()) { - if (parent_folder->potentiallyVisible() && !parent_folder->getHidden()) + if (parent_folder->potentiallyVisible()) { // give initial selection to first ancestor folder that potentially passes the filter if (!new_selection) @@ -808,11 +815,6 @@ void LLFolderView::sanitizeSelection() { // nothing selected to start with, so pick "My Inventory" as best guess new_selection = getItemByID(gInventory.getRootFolderID()); - // ... except if it's hidden from the UI. - if (new_selection && new_selection->getHidden()) - { - new_selection = NULL; - } } if (new_selection) @@ -962,7 +964,9 @@ void LLFolderView::draw() } - LLFolderViewFolder::draw(); + // skip over LLFolderViewFolder::draw since we don't want the folder icon, label, + // and arrow for the root folder + LLView::draw(); mDragAndDropThisFrame = FALSE; } @@ -1642,11 +1646,7 @@ BOOL LLFolderView::handleKeyHere( KEY key, MASK mask ) LLFolderViewItem* parent_folder = last_selected->getParentFolder(); if (!last_selected->isOpen() && parent_folder && parent_folder->getParentFolder()) { - // Don't change selectin to hidden folder. See EXT-5328. - if (!parent_folder->getHidden()) - { - setSelection(parent_folder, FALSE, TRUE); - } + setSelection(parent_folder, FALSE, TRUE); } else { @@ -2031,7 +2031,7 @@ void LLFolderView::removeItemID(const LLUUID& id) LLFolderViewItem* LLFolderView::getItemByID(const LLUUID& id) { - if (id.isNull()) + if (id == getListener()->getUUID()) { return this; } @@ -2048,7 +2048,7 @@ LLFolderViewItem* LLFolderView::getItemByID(const LLUUID& id) LLFolderViewFolder* LLFolderView::getFolderByID(const LLUUID& id) { - if (id.isNull()) + if (id == getListener()->getUUID()) { return this; } @@ -2496,11 +2496,6 @@ BOOL LLFolderView::isFilterModified() return mFilter->isNotDefault(); } -BOOL LLFolderView::getAllowMultiSelect() -{ - return mAllowMultiSelect; -} - void delete_selected_item(void* user_data) { if(user_data) diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 1464a058d8..12f6170a7d 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -89,7 +89,11 @@ public: Mandatory parent_panel; Optional task_id; Optional title; - Optional use_label_suffix; + Optional use_label_suffix, + allow_multiselect, + use_ellipses; + + Params(); }; LLFolderView(const Params&); virtual ~LLFolderView( void ); @@ -102,7 +106,6 @@ public: // and resort the items if necessary. void setSortOrder(U32 order); void setFilterPermMask(PermissionMask filter_perm_mask); - void setAllowMultiSelect(BOOL allow) { mAllowMultiSelect = allow; } typedef boost::signals2::signal& items, BOOL user_action)> signal_t; void setSelectCallback(const signal_t::slot_type& cb) { mSelectSignal.connect(cb); } @@ -117,7 +120,6 @@ public: //LLInventoryFilter::EFolderShow getShowFolderState(); U32 getSortOrder() const; BOOL isFilterModified(); - BOOL getAllowMultiSelect(); // Close all folders in the view void closeAllFolders(); @@ -238,7 +240,6 @@ public: void setShowSingleSelection(BOOL show); BOOL getShowSingleSelection() { return mShowSingleSelection; } F32 getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); } - void setUseEllipses(bool use_ellipses) { mUseEllipses = use_ellipses; } bool getUseEllipses() { return mUseEllipses; } void addItemID(const LLUUID& id, LLFolderViewItem* itemp); diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index e9d1ad3a9e..904c233850 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -132,8 +132,13 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mListener(p.listener), mHidden(false), mShowLoadStatus(false) +{ +} + +BOOL LLFolderViewItem::postBuild() { refresh(); + return TRUE; } // Destroys the object @@ -195,7 +200,7 @@ LLFolderViewItem* LLFolderViewItem::getPreviousOpenNode(BOOL include_children) LLFolderViewItem* itemp = mParentFolder->getPreviousFromChild( this, include_children ); // Skip over items that are invisible or are hidden from the UI. - while(itemp && (!itemp->getVisible() || itemp->getHidden())) + while(itemp && !itemp->getVisible()) { LLFolderViewItem* next_itemp = itemp->mParentFolder->getPreviousFromChild( itemp, include_children ); if (itemp == next_itemp) @@ -351,7 +356,10 @@ void LLFolderViewItem::arrangeAndSet(BOOL set_selection, BOOL take_keyboard_focus) { LLFolderView* root = getRoot(); - getParentFolder()->requestArrange(); + if (getParentFolder()) + { + getParentFolder()->requestArrange(); + } if(set_selection) { setSelectionFromRoot(this, TRUE, take_keyboard_focus); @@ -442,23 +450,20 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) S32 LLFolderViewItem::getItemHeight() { - if (getHidden()) return 0; - return mItemHeight; } void LLFolderViewItem::filter( LLInventoryFilter& filter) { const BOOL previous_passed_filter = mPassedFilter; - const BOOL passed_filter = mListener && filter.check(this); + const BOOL passed_filter = filter.check(this); // If our visibility will change as a result of this filter, then // we need to be rearranged in our parent folder if (mParentFolder) { - if (getVisible() != passed_filter) - mParentFolder->requestArrange(); - if (passed_filter != previous_passed_filter) + if (getVisible() != passed_filter + || previous_passed_filter != passed_filter ) mParentFolder->requestArrange(); } @@ -863,11 +868,6 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, void LLFolderViewItem::draw() { - if (getHidden()) - { - return; - } - static LLUIColor sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); static LLUIColor sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE); static LLUIColor sHighlightFgColor = LLUIColorTable::instance().getColor("MenuItemHighlightFgColor", DEFAULT_WHITE); @@ -891,8 +891,8 @@ void LLFolderViewItem::draw() // Draw open folder arrow // const bool up_to_date = mListener && mListener->isUpToDate(); - const bool possibly_has_children = ((up_to_date && hasVisibleChildren()) || // we fetched our children and some of them have passed the filter... - (!up_to_date && mListener && mListener->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter) + const bool possibly_has_children = ((up_to_date && hasVisibleChildren()) // we fetched our children and some of them have passed the filter... + || (!up_to_date && mListener && mListener->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter) if (possibly_has_children) { LLUIImage* arrow_image = default_params.folder_arrow_image; @@ -1054,8 +1054,11 @@ void LLFolderViewItem::draw() { root_is_loading = LLInventoryModelBackgroundFetch::instance().libraryFetchInProgress(); } - if ((mIsLoading && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime")) || - (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && root_is_loading && (mShowLoadStatus || mHidden))) + if ((mIsLoading + && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime")) + || (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() + && root_is_loading + && (mShowLoadStatus || mHidden))) { std::string load_string = " ( " + LLTrans::getString("LoadingData") + " ) "; font->renderUTF8(load_string, 0, right_x, y, sSearchStatusColor, @@ -1119,7 +1122,8 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): mLastCalculatedWidth(0), mCompletedFilterGeneration(-1), mMostFilteredDescendantGeneration(-1), - mNeedsSort(false) + mNeedsSort(false), + mPassedFolderFilter(FALSE) { } @@ -1131,6 +1135,17 @@ LLFolderViewFolder::~LLFolderViewFolder( void ) gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() } +void LLFolderViewFolder::setFilteredFolder(bool filtered, S32 filter_generation) +{ + mPassedFolderFilter = filtered; + mLastFilterGeneration = filter_generation; +} + +bool LLFolderViewFolder::getFilteredFolder(S32 filter_generation) +{ + return mPassedFolderFilter && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration(); +} + // addToFolder() returns TRUE if it succeeds. FALSE otherwise BOOL LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder, LLFolderView* root) { @@ -1190,8 +1205,10 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) } else { - folderp->setVisible(show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders? - (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter + folderp->setVisible( + folderp->getFilteredFolder(filter_generation) // folder must pass folder filters + && (folderp->getFiltered(filter_generation) + || folderp->hasFilteredDescendants(filter_generation))); // passed item filter or has descendants that passed filter } if (folderp->getVisible()) @@ -1311,7 +1328,9 @@ void LLFolderViewFolder::setCompletedFilterGeneration(S32 generation, BOOL recur mMostFilteredDescendantGeneration = llmin(mMostFilteredDescendantGeneration, generation); mCompletedFilterGeneration = generation; // only aggregate up if we are a lower (older) value - if (recurse_up && mParentFolder && generation < mParentFolder->getCompletedFilterGeneration()) + if (recurse_up + && mParentFolder + && generation < mParentFolder->getCompletedFilterGeneration()) { mParentFolder->setCompletedFilterGeneration(generation, TRUE); } @@ -1336,15 +1355,17 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) // filter folder itself if (getLastFilterGeneration() < filter_generation) { - if (getLastFilterGeneration() >= must_pass_generation && // folder has been compared to a valid precursor filter - !mPassedFilter) // and did not pass the filter + if (getLastFilterGeneration() >= must_pass_generation // folder has been compared to a valid precursor filter + && !mPassedFilter) // and did not pass the filter { // go ahead and flag this folder as done mLastFilterGeneration = filter_generation; } - else + else // filter self only on first pass through { - // filter self only on first pass through + // filter against folder rules + filterFolder(filter); + // and then item rules LLFolderViewItem::filter( filter ); } if (mHidden) @@ -1377,7 +1398,10 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) } // when applying a filter, matching folders get their contents downloaded first - if (filter.isNotDefault() && getFiltered(filter.getMinRequiredGeneration()) && (mListener && !gInventory.isCategoryComplete(mListener->getUUID()))) + if (filter.isNotDefault() + && getFiltered(filter.getMinRequiredGeneration()) + && (mListener + && !gInventory.isCategoryComplete(mListener->getUUID()))) { LLInventoryModelBackgroundFetch::instance().start(mListener->getUUID()); } @@ -1467,6 +1491,31 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) } } +void LLFolderViewFolder::filterFolder(LLInventoryFilter& filter) +{ + const BOOL previous_passed_filter = mPassedFolderFilter; + const BOOL passed_filter = filter.checkFolder(this); + + // If our visibility will change as a result of this filter, then + // we need to be rearranged in our parent folder + if (mParentFolder) + { + if (getVisible() != passed_filter + || previous_passed_filter != passed_filter ) + { + mParentFolder->requestArrange(); + } + } + + setFilteredFolder(passed_filter, filter.getCurrentGeneration()); + filter.decrementFilterCount(); + + if (getRoot()->getDebugFilters()) + { + mStatusText = llformat("%d", mLastFilterGeneration); + } +} + void LLFolderViewFolder::setFiltered(BOOL filtered, S32 filter_generation) { // if this folder is now filtered, but wasn't before @@ -2059,7 +2108,9 @@ void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType r (*fit)->setOpenArrangeRecursively(openitem, RECURSE_DOWN); /* Flawfinder: ignore */ } } - if (mParentFolder && (recurse == RECURSE_UP || recurse == RECURSE_UP_DOWN)) + if (mParentFolder + && (recurse == RECURSE_UP + || recurse == RECURSE_UP_DOWN)) { mParentFolder->setOpenArrangeRecursively(openitem, RECURSE_UP); } @@ -2301,13 +2352,16 @@ void LLFolderViewFolder::draw() bool possibly_has_children = false; bool up_to_date = mListener && mListener->isUpToDate(); - if(!up_to_date && mListener && mListener->hasChildren()) // we know we have children but haven't fetched them (doesn't obey filter) + if(!up_to_date + && mListener->hasChildren()) // we know we have children but haven't fetched them (doesn't obey filter) { possibly_has_children = true; } - BOOL loading = ( mIsOpen && possibly_has_children && !up_to_date ); + BOOL loading = (mIsOpen + && possibly_has_children + && !up_to_date ); if ( loading && !mIsLoading ) { @@ -2573,7 +2627,8 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde { // ignore sort order for landmarks in the Favorites folder. // they should be always sorted as in Favorites bar. See EXT-719 - if (a->getSortGroup() == SG_ITEM && b->getSortGroup() == SG_ITEM + if (a->getSortGroup() == SG_ITEM + && b->getSortGroup() == SG_ITEM && a->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK && b->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK) { @@ -2600,8 +2655,8 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde // We sort by name if we aren't sorting by date // OR if these are folders and we are sorting folders by name. bool by_name = (!mByDate - || (mFoldersByName - && (a->getSortGroup() != SG_ITEM))); + || (mFoldersByName + && (a->getSortGroup() != SG_ITEM))); if (a->getSortGroup() != b->getSortGroup()) { diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index fc941510ab..c48e568b30 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -174,6 +174,8 @@ protected: static LLFontGL* getLabelFontForStyle(U8 style); public: + BOOL postBuild(); + // This function clears the currently selected item, and records // the specified selected item appropriately for display and use // in the UI. If open is TRUE, then folders are opened up along @@ -202,11 +204,6 @@ public: virtual S32 arrange( S32* width, S32* height, S32 filter_generation ); virtual S32 getItemHeight(); - // Hide the folder from the UI, such as if you want to hide the root - // folder in an inventory panel. - void setHidden(bool hidden) { mHidden = hidden; } - bool getHidden() const { return mHidden; } - // applies filters to control visibility of inventory items virtual void filter( LLInventoryFilter& filter); @@ -392,6 +389,8 @@ protected: S32 mCompletedFilterGeneration; S32 mMostFilteredDescendantGeneration; bool mNeedsSort; + bool mPassedFolderFilter; + public: typedef enum e_recurse_type { @@ -432,6 +431,11 @@ public: virtual void filter( LLInventoryFilter& filter); virtual void setFiltered(BOOL filtered, S32 filter_generation); virtual void dirtyFilter(); + + // folder-specific filtering (filter status propagates top down instead of bottom up) + void filterFolder(LLInventoryFilter& filter); + void setFilteredFolder(bool filtered, S32 filter_generation); + bool getFilteredFolder(S32 filter_generation); // Passes selection information on to children and record // selection information if necessary. diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index dee15a1efd..49e0ab33e5 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -107,6 +107,31 @@ BOOL LLInventoryFilter::check(const LLFolderViewItem* item) return passed; } +bool LLInventoryFilter::checkFolder(const LLFolderViewFolder* folder) +{ + // we're showing all folders, overriding filter + if (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS) + { + return true; + } + + const LLFolderViewEventListener* listener = folder->getListener(); + const LLUUID folder_id = listener->getUUID(); + + if (mFilterOps.mFilterTypes & FILTERTYPE_CATEGORY) + { + // Can only filter categories for items in your inventory + // (e.g. versus in-world object contents). + const LLViewerInventoryCategory *cat = gInventory.getCategory(folder_id); + if (!cat) + return false; + if ((1LL << cat->getPreferredType() & mFilterOps.mFilterCategoryTypes) == U64(0)) + return false; + } + + return true; +} + BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) const { const LLFolderViewEventListener* listener = item->getListener(); @@ -137,30 +162,6 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con } } - - //////////////////////////////////////////////////////////////////////////////// - // FILTERTYPE_CATEGORY - // Pass if this item is a category of the filter type, or - // if its parent is a category of the filter type. - if (filterTypes & FILTERTYPE_CATEGORY) - { - // Can only filter categories for items in your inventory - // (e.g. versus in-world object contents). - if (!object) return FALSE; - - LLUUID cat_id = object_id; - if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY) - { - cat_id = object->getParentUUID(); - } - const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); - if (!cat) - return FALSE; - if ((1LL << cat->getPreferredType() & mFilterOps.mFilterCategoryTypes) == U64(0)) - return FALSE; - } - - //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_UUID // Pass if this item is the target UUID or if it links to the target UUID @@ -172,7 +173,6 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con return FALSE; } - //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_DATE // Pass if this item is within the date range. @@ -293,15 +293,15 @@ BOOL LLInventoryFilter::isModifiedAndClear() return ret; } -void LLInventoryFilter::setFilterObjectTypes(U64 types) +void LLInventoryFilter::updateFilterTypes(U64 types, U64& current_types) { - if (mFilterOps.mFilterObjectTypes != types) + if (current_types != types) { // keep current items only if no type bits getting turned off - BOOL fewer_bits_set = (mFilterOps.mFilterObjectTypes & ~types); - BOOL more_bits_set = (~mFilterOps.mFilterObjectTypes & types); + BOOL fewer_bits_set = (current_types & ~types); + BOOL more_bits_set = (~current_types & types); - mFilterOps.mFilterObjectTypes = types; + current_types = types; if (more_bits_set && fewer_bits_set) { // neither less or more restrive, both simultaneously @@ -318,62 +318,23 @@ void LLInventoryFilter::setFilterObjectTypes(U64 types) setModified(FILTER_MORE_RESTRICTIVE); } } +} + +void LLInventoryFilter::setFilterObjectTypes(U64 types) +{ + updateFilterTypes(types, mFilterOps.mFilterObjectTypes); mFilterOps.mFilterTypes |= FILTERTYPE_OBJECT; } void LLInventoryFilter::setFilterCategoryTypes(U64 types) { - if (mFilterOps.mFilterCategoryTypes != types) - { - // keep current items only if no type bits getting turned off - BOOL fewer_bits_set = (mFilterOps.mFilterCategoryTypes & ~types); - BOOL more_bits_set = (~mFilterOps.mFilterCategoryTypes & types); - - mFilterOps.mFilterCategoryTypes = types; - if (more_bits_set && fewer_bits_set) - { - // neither less or more restrive, both simultaneously - // so we need to filter from scratch - setModified(FILTER_RESTART); - } - else if (more_bits_set) - { - // target is only one of all requested types so more type bits == less restrictive - setModified(FILTER_LESS_RESTRICTIVE); - } - else if (fewer_bits_set) - { - setModified(FILTER_MORE_RESTRICTIVE); - } - } - mFilterOps.mFilterTypes |= FILTERTYPE_OBJECT; + updateFilterTypes(types, mFilterOps.mFilterCategoryTypes); + mFilterOps.mFilterTypes |= FILTERTYPE_CATEGORY; } void LLInventoryFilter::setFilterWearableTypes(U64 types) { - if (mFilterOps.mFilterWearableTypes != types) - { - // keep current items only if no type bits getting turned off - BOOL fewer_bits_set = (mFilterOps.mFilterWearableTypes & ~types); - BOOL more_bits_set = (~mFilterOps.mFilterWearableTypes & types); - - mFilterOps.mFilterWearableTypes = types; - if (more_bits_set && fewer_bits_set) - { - // neither less or more restrive, both simultaneously - // so we need to filter from scratch - setModified(FILTER_RESTART); - } - else if (more_bits_set) - { - // target is only one of all requested types so more type bits == less restrictive - setModified(FILTER_LESS_RESTRICTIVE); - } - else if (fewer_bits_set) - { - setModified(FILTER_MORE_RESTRICTIVE); - } - } + updateFilterTypes(types, mFilterOps.mFilterWearableTypes); mFilterOps.mFilterTypes |= FILTERTYPE_WEARABLE; } @@ -898,11 +859,16 @@ void LLInventoryFilter::fromLLSD(LLSD& data) } } -U32 LLInventoryFilter::getFilterObjectTypes() const +U64 LLInventoryFilter::getFilterObjectTypes() const { return mFilterOps.mFilterObjectTypes; } +U64 LLInventoryFilter::getFilterCategoryTypes() const +{ + return mFilterOps.mFilterCategoryTypes; +} + BOOL LLInventoryFilter::hasFilterString() const { return mFilterSubString.size() > 0; diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 39e6f797a2..f9460822f7 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -31,6 +31,7 @@ #include "llpermissionsflags.h" class LLFolderViewItem; +class LLFolderViewFolder; class LLInventoryFilter { @@ -81,11 +82,13 @@ public: // + Parameters // +-------------------------------------------------------------------+ void setFilterObjectTypes(U64 types); - U32 getFilterObjectTypes() const; + U64 getFilterObjectTypes() const; + U64 getFilterCategoryTypes() const; BOOL isFilterObjectTypesWith(LLInventoryType::EType t) const; void setFilterCategoryTypes(U64 types); void setFilterUUID(const LLUUID &object_id); void setFilterWearableTypes(U64 types); + void updateFilterTypes(U64 types, U64& current_types); void setFilterSubString(const std::string& string); const std::string& getFilterSubString(BOOL trim = FALSE) const; @@ -110,6 +113,7 @@ public: // + Execution And Results // +-------------------------------------------------------------------+ BOOL check(const LLFolderViewItem* item); + bool checkFolder(const LLFolderViewFolder* folder); BOOL checkAgainstFilterType(const LLFolderViewItem* item) const; BOOL checkAgainstPermissions(const LLFolderViewItem* item) const; BOOL checkAgainstFilterLinks(const LLFolderViewItem* item) const; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 1dcb91ad4d..1ff423056a 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -132,8 +132,6 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : mAllowMultiSelect(p.allow_multi_select), mShowItemLinkOverlays(p.show_item_link_overlays), mViewsInitialized(false), - mStartFolderString(p.start_folder), - mBuildDefaultHierarchy(true), mInvFVBridgeBuilder(NULL) { mInvFVBridgeBuilder = &INVENTORY_BRIDGE_BUILDER; @@ -146,11 +144,48 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : mCommitCallbackRegistrar.add("Inventory.AttachObject", boost::bind(&LLInventoryPanel::attachObject, this, _2)); mCommitCallbackRegistrar.add("Inventory.BeginIMSession", boost::bind(&LLInventoryPanel::beginIMSession, this)); mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars)); - - if (mStartFolderString != "") + +} + +void LLInventoryPanel::buildFolderView(const LLInventoryPanel::Params& params) +{ + // Determine the root folder in case specified, and + // build the views starting with that folder. + const LLFolderType::EType preferred_type = LLViewerFolderType::lookupTypeFromNewCategoryName(params.start_folder); + + LLUUID root_id; + + if ("LIBRARY" == params.start_folder()) { - mBuildDefaultHierarchy = false; + root_id = gInventory.getLibraryRootFolderID(); } + else + { + root_id = (preferred_type != LLFolderType::FT_NONE) + ? gInventory.findCategoryUUIDForType(preferred_type) + : LLUUID::null; + } + + LLRect folder_rect(0, + 0, + getRect().getWidth(), + 0); + LLFolderView::Params p; + p.name = getName(); + p.title = getLabel(); + p.rect = folder_rect; + p.parent_panel = this; + p.tool_tip = p.name; + p.listener = mInvFVBridgeBuilder->createBridge(LLAssetType::AT_CATEGORY, + LLAssetType::AT_CATEGORY, + LLInventoryType::IT_CATEGORY, + this, + NULL, + root_id); + p.use_label_suffix = params.use_label_suffix; + p.allow_multiselect = mAllowMultiSelect; + mFolderRoot = LLUICtrlFactory::create(p); + } void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) @@ -159,22 +194,7 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves - // Create root folder - { - LLRect folder_rect(0, - 0, - getRect().getWidth(), - 0); - LLFolderView::Params p; - p.name = getName(); - p.title = getLabel(); - p.rect = folder_rect; - p.parent_panel = this; - p.tool_tip = p.name; - p.use_label_suffix = params.use_label_suffix; - mFolderRoot = LLUICtrlFactory::create(p); - mFolderRoot->setAllowMultiSelect(mAllowMultiSelect); - } + buildFolderView(params); mCommitCallbackRegistrar.popScope(); @@ -206,7 +226,7 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) // Build view of inventory if we need default full hierarchy and inventory ready, // otherwise wait for idle callback. - if (mBuildDefaultHierarchy && mInventory->isInventoryUsable() && !mViewsInitialized) + if (mInventory->isInventoryUsable() && !mViewsInitialized) { initializeViews(); } @@ -264,6 +284,15 @@ LLInventoryFilter* LLInventoryPanel::getFilter() return NULL; } +const LLInventoryFilter* LLInventoryPanel::getFilter() const +{ + if (mFolderRoot) + { + return mFolderRoot->getFilter(); + } + return NULL; +} + void LLInventoryPanel::setFilterTypes(U64 types, LLInventoryFilter::EFilterType filter_type) { if (filter_type == LLInventoryFilter::FILTERTYPE_OBJECT) @@ -488,23 +517,16 @@ void LLInventoryPanel::onIdle(void *userdata) } } +const LLUUID& LLInventoryPanel::getRootFolderID() const +{ + return mFolderRoot->getListener()->getUUID(); +} + void LLInventoryPanel::initializeViews() { if (!gInventory.isInventoryUsable()) return; - // Determine the root folder in case specified, and - // build the views starting with that folder. - const LLFolderType::EType preferred_type = LLViewerFolderType::lookupTypeFromNewCategoryName(mStartFolderString); - - if ("LIBRARY" == mStartFolderString) - { - mStartFolderID = gInventory.getLibraryRootFolderID(); - } - else - { - mStartFolderID = (preferred_type != LLFolderType::FT_NONE ? gInventory.findCategoryUUIDForType(preferred_type) : LLUUID::null); - } - rebuildViewsFor(mStartFolderID); + rebuildViewsFor(getRootFolderID()); mViewsInitialized = true; @@ -533,7 +555,7 @@ void LLInventoryPanel::rebuildViewsFor(const LLUUID& id) { // Destroy the old view for this ID so we can rebuild it. LLFolderViewItem* old_view = mFolderRoot->getItemByID(id); - if (old_view && id.notNull()) + if (old_view && old_view != mFolderRoot) { old_view->destroyView(); } @@ -543,118 +565,101 @@ void LLInventoryPanel::rebuildViewsFor(const LLUUID& id) void LLInventoryPanel::buildNewViews(const LLUUID& id) { - LLMemType mt(LLMemType::MTYPE_INVENTORY_BUILD_NEW_VIEWS); - LLFolderViewItem* itemp = NULL; - LLInventoryObject* objectp = gInventory.getObject(id); - if (objectp) - { - const LLUUID &parent_id = objectp->getParentUUID(); - LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id); - if (id == mStartFolderID) - { - parent_folder = mFolderRoot; - } - else if ((mStartFolderID != LLUUID::null) && (!gInventory.isObjectDescendentOf(id, mStartFolderID))) - { - // This item exists outside the inventory's hierarchy, so don't add it. - return; - } - - if (objectp->getType() <= LLAssetType::AT_NONE || - objectp->getType() >= LLAssetType::AT_COUNT) - { - llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : " - << ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID() - << llendl; - return; - } - - if ((objectp->getType() == LLAssetType::AT_CATEGORY) && - (objectp->getActualType() != LLAssetType::AT_LINK_FOLDER)) - { - LLInvFVBridge* new_listener = mInvFVBridgeBuilder->createBridge(objectp->getType(), - objectp->getType(), - LLInventoryType::IT_CATEGORY, - this, - mFolderRoot, - objectp->getUUID()); - if (new_listener) - { - LLFolderViewFolder::Params params; - params.name = new_listener->getDisplayName(); - params.icon = new_listener->getIcon(); - params.icon_open = new_listener->getOpenIcon(); - if (mShowItemLinkOverlays) // if false, then links show up just like normal items - { - params.icon_overlay = LLUI::getUIImage("Inv_Link"); - } - params.root = mFolderRoot; - params.listener = new_listener; - params.tool_tip = params.name; - LLFolderViewFolder* folderp = LLUICtrlFactory::create(params); - folderp->setItemSortOrder(mFolderRoot->getSortOrder()); - itemp = folderp; - - // Hide the root folder, so we can show the contents of a folder flat - // but still have the parent folder present for listener-related operations. - if (id == mStartFolderID) - { - folderp->setHidden(TRUE); - } - const LLViewerInventoryCategory *cat = dynamic_cast(objectp); - if (cat && getIsHiddenFolderType(cat->getPreferredType())) - { - folderp->setHidden(TRUE); - } - } - } - else - { - // Build new view for item. - LLInventoryItem* item = (LLInventoryItem*)objectp; - LLInvFVBridge* new_listener = mInvFVBridgeBuilder->createBridge(item->getType(), - item->getActualType(), - item->getInventoryType(), - this, - mFolderRoot, - item->getUUID(), - item->getFlags()); - - if (new_listener) - { - LLFolderViewItem::Params params; - params.name = new_listener->getDisplayName(); - params.icon = new_listener->getIcon(); - params.icon_open = new_listener->getOpenIcon(); - if (mShowItemLinkOverlays) // if false, then links show up just like normal items - { - params.icon_overlay = LLUI::getUIImage("Inv_Link"); - } - params.creation_date = new_listener->getCreationDate(); - params.root = mFolderRoot; - params.listener = new_listener; - params.rect = LLRect (0, 0, 0, 0); - params.tool_tip = params.name; - itemp = LLUICtrlFactory::create (params); - } - } - - if (itemp) - { - itemp->addToFolder(parent_folder, mFolderRoot); - - // Don't add children of hidden folders unless this is the panel's root folder. - if (itemp->getHidden() && (id != mStartFolderID)) - { - return; - } + LLInventoryObject const* objectp = gInventory.getObject(id); + LLUUID root_id = mFolderRoot->getListener()->getUUID(); + LLFolderViewFolder* parent_folder = NULL; + + if (id == root_id) + { + parent_folder = mFolderRoot; + } + else if (objectp) + { + LLFolderViewItem* itemp = NULL; + const LLUUID &parent_id = objectp->getParentUUID(); + parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id); + + if (parent_folder) + { + if (objectp->getType() <= LLAssetType::AT_NONE || + objectp->getType() >= LLAssetType::AT_COUNT) + { + llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : " + << ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID() + << llendl; + return; + } + + if ((objectp->getType() == LLAssetType::AT_CATEGORY) && + (objectp->getActualType() != LLAssetType::AT_LINK_FOLDER)) + { + LLInvFVBridge* new_listener = mInvFVBridgeBuilder->createBridge(objectp->getType(), + objectp->getType(), + LLInventoryType::IT_CATEGORY, + this, + mFolderRoot, + objectp->getUUID()); + if (new_listener) + { + LLFolderViewFolder::Params params; + params.name = new_listener->getDisplayName(); + params.icon = new_listener->getIcon(); + params.icon_open = new_listener->getOpenIcon(); + if (mShowItemLinkOverlays) // if false, then links show up just like normal items + { + params.icon_overlay = LLUI::getUIImage("Inv_Link"); + } + params.root = mFolderRoot; + params.listener = new_listener; + params.tool_tip = params.name; + LLFolderViewFolder* folderp = LLUICtrlFactory::create(params); + folderp->setItemSortOrder(mFolderRoot->getSortOrder()); + itemp = folderp; + } + } + else + { + // Build new view for item. + LLInventoryItem* item = (LLInventoryItem*)objectp; + LLInvFVBridge* new_listener = mInvFVBridgeBuilder->createBridge(item->getType(), + item->getActualType(), + item->getInventoryType(), + this, + mFolderRoot, + item->getUUID(), + item->getFlags()); + + if (new_listener) + { + LLFolderViewItem::Params params; + params.name = new_listener->getDisplayName(); + params.icon = new_listener->getIcon(); + params.icon_open = new_listener->getOpenIcon(); + if (mShowItemLinkOverlays) // if false, then links show up just like normal items + { + params.icon_overlay = LLUI::getUIImage("Inv_Link"); + } + params.creation_date = new_listener->getCreationDate(); + params.root = mFolderRoot; + params.listener = new_listener; + params.rect = LLRect (0, 0, 0, 0); + params.tool_tip = params.name; + itemp = LLUICtrlFactory::create (params); + } + } + + if (itemp) + { + itemp->addToFolder(parent_folder, mFolderRoot); + } } } // If this is a folder, add the children of the folder and recursively add any // child folders. - if ((id == mStartFolderID) || - (objectp && objectp->getType() == LLAssetType::AT_CATEGORY)) + if (id.isNull() + || (objectp + && objectp->getType() == LLAssetType::AT_CATEGORY)) { LLViewerInventoryCategory::cat_array_t* categories; LLViewerInventoryItem::item_array_t* items; @@ -671,7 +676,7 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) } } - if(items) + if(items && parent_folder) { for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items->begin(); item_iter != items->end(); @@ -688,23 +693,17 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) // bit of a hack to make sure the inventory is open. void LLInventoryPanel::openStartFolderOrMyInventory() { - if (mStartFolderString != "") - { - mFolderRoot->openFolder(mStartFolderString); - } - else + // Find My Inventory folder and open it up by name + for (LLView *child = mFolderRoot->getFirstChild(); child; child = mFolderRoot->findNextSibling(child)) { - // Find My Inventory folder and open it up by name - for (LLView *child = mFolderRoot->getFirstChild(); child; child = mFolderRoot->findNextSibling(child)) + LLFolderViewFolder *fchild = dynamic_cast(child); + if (fchild + && fchild->getListener() + && fchild->getListener()->getUUID() == gInventory.getRootFolderID()) { - LLFolderViewFolder *fchild = dynamic_cast(child); - if (fchild && fchild->getListener() && - (fchild->getListener()->getUUID() == gInventory.getRootFolderID())) - { - const std::string& child_name = child->getName(); - mFolderRoot->openFolder(child_name); - break; - } + const std::string& child_name = child->getName(); + mFolderRoot->openFolder(child_name); + break; } } } @@ -1067,15 +1066,12 @@ LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open) void LLInventoryPanel::addHideFolderType(LLFolderType::EType folder_type) { - if (!getIsHiddenFolderType(folder_type)) - { - mHiddenFolderTypes.push_back(folder_type); - } + getFilter()->setFilterCategoryTypes(getFilter()->getFilterCategoryTypes() & ~(1ULL << folder_type)); } BOOL LLInventoryPanel::getIsHiddenFolderType(LLFolderType::EType folder_type) const { - return (std::find(mHiddenFolderTypes.begin(), mHiddenFolderTypes.end(), folder_type) != mHiddenFolderTypes.end()); + return !(getFilter()->getFilterCategoryTypes() & (1ULL << folder_type)); } diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 9da9f7d8ba..da67da13b2 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -126,6 +126,7 @@ public: void setSelectCallback(const LLFolderView::signal_t::slot_type& cb); void clearSelection(); LLInventoryFilter* getFilter(); + const LLInventoryFilter* getFilter() const; void setFilterTypes(U64 filter, LLInventoryFilter::EFilterType = LLInventoryFilter::FILTERTYPE_OBJECT); U32 getFilterObjectTypes() const { return mFolderRoot->getFilterObjectTypes(); } void setFilterPermMask(PermissionMask filter_perm_mask); @@ -140,7 +141,6 @@ public: void setShowFolderState(LLInventoryFilter::EFolderShow show); LLInventoryFilter::EFolderShow getShowFolderState(); - void setAllowMultiSelect(BOOL allow) { mFolderRoot->setAllowMultiSelect(allow); } // This method is called when something has changed about the inventory. void modelChanged(U32 mask); LLFolderView* getRootFolder() { return mFolderRoot; } @@ -207,23 +207,18 @@ private: //-------------------------------------------------------------------- public: void addHideFolderType(LLFolderType::EType folder_type); -protected: - BOOL getIsHiddenFolderType(LLFolderType::EType folder_type) const; -private: - std::vector mHiddenFolderTypes; - //-------------------------------------------------------------------- - // Initialization routines for building up the UI ("views") - //-------------------------------------------------------------------- public: BOOL getIsViewsInitialized() const { return mViewsInitialized; } - const LLUUID& getStartFolderID() const { return mStartFolderID; } - const std::string& getStartFolderString() { return mStartFolderString; } + const LLUUID& getRootFolderID() const; protected: // Builds the UI. Call this once the inventory is usable. void initializeViews(); - void rebuildViewsFor(const LLUUID& id); // Given the id and the parent, build all of the folder views. - virtual void buildNewViews(const LLUUID& id); + void rebuildViewsFor(const LLUUID& id); // Given the id and the parent, build all of the folder views. + + virtual void buildFolderView(const LLInventoryPanel::Params& params); + virtual void buildNewViews(const LLUUID& id); + BOOL getIsHiddenFolderType(LLFolderType::EType folder_type) const; private: BOOL mBuildDefaultHierarchy; // default inventory hierarchy should be created in postBuild() BOOL mViewsInitialized; // Views have been generated diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 80f6862169..f09f675b75 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -645,7 +645,7 @@ void LLLandmarksPanel::onAccordionExpandedCollapsed(const LLSD& param, LLPlacesI // Start background fetch, mostly for My Inventory and Library if (expanded) { - const LLUUID &cat_id = inventory_list->getStartFolderID(); + const LLUUID &cat_id = inventory_list->getRootFolderID(); // Just because the category itself has been fetched, doesn't mean its child folders have. /* if (!gInventory.isCategoryComplete(cat_id)) @@ -1414,7 +1414,7 @@ static void filter_list(LLPlacesInventoryPanel* inventory_list, const std::strin static bool category_has_descendents(LLPlacesInventoryPanel* inventory_list) { - LLViewerInventoryCategory* category = gInventory.getCategory(inventory_list->getStartFolderID()); + LLViewerInventoryCategory* category = gInventory.getCategory(inventory_list->getRootFolderID()); if (category) { return category->getDescendentCount() > 0; diff --git a/indra/newview/llplacesinventorypanel.cpp b/indra/newview/llplacesinventorypanel.cpp index 29e262199e..f7823f4fe8 100644 --- a/indra/newview/llplacesinventorypanel.cpp +++ b/indra/newview/llplacesinventorypanel.cpp @@ -35,6 +35,7 @@ #include "llinventoryfunctions.h" #include "llpanellandmarks.h" #include "llplacesinventorybridge.h" +#include "llviewerfoldertype.h" static LLDefaultChildRegistry::Register r("places_inventory_panel"); @@ -56,72 +57,44 @@ LLPlacesInventoryPanel::~LLPlacesInventoryPanel() delete mSavedFolderState; } -BOOL LLPlacesInventoryPanel::postBuild() +void LLPlacesInventoryPanel::buildFolderView(const LLInventoryPanel::Params& params) { - LLInventoryPanel::postBuild(); + // Determine the root folder in case specified, and + // build the views starting with that folder. + const LLFolderType::EType preferred_type = LLViewerFolderType::lookupTypeFromNewCategoryName(params.start_folder); - // clear Contents(); - { - mFolderRoot->destroyView(); - mFolderRoot->getParent()->removeChild(mFolderRoot); - mFolderRoot->die(); - - if( mScroller ) - { - removeChild( mScroller ); - mScroller->die(); - mScroller = NULL; - } - mFolderRoot = NULL; - } - - - mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves + LLUUID root_id; - // create root folder + if ("LIBRARY" == params.start_folder()) { - LLRect folder_rect(0, - 0, - getRect().getWidth(), - 0); - LLPlacesFolderView::Params p; - p.name = getName(); - p.title = getLabel(); - p.rect = folder_rect; - p.parent_panel = this; - mFolderRoot = (LLFolderView*)LLUICtrlFactory::create(p); - mFolderRoot->setAllowMultiSelect(mAllowMultiSelect); + root_id = gInventory.getLibraryRootFolderID(); } - - mCommitCallbackRegistrar.popScope(); - - mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); - - // scroller + else { - LLRect scroller_view_rect = getRect(); - scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); - LLScrollContainer::Params p; - p.name("Inventory Scroller"); - p.rect(scroller_view_rect); - p.follows.flags(FOLLOWS_ALL); - p.reserve_scroll_corner(true); - p.tab_stop(true); - mScroller = LLUICtrlFactory::create(p); + root_id = (preferred_type != LLFolderType::FT_NONE ? gInventory.findCategoryUUIDForType(preferred_type) : LLUUID::null); } - addChild(mScroller); - mScroller->addChild(mFolderRoot); - - mFolderRoot->setScrollContainer(mScroller); - mFolderRoot->addChild(mFolderRoot->mStatusTextBox); - - // cut subitems - mFolderRoot->setUseEllipses(true); - - return TRUE; + LLRect folder_rect(0, + 0, + getRect().getWidth(), + 0); + LLPlacesFolderView::Params p; + p.name = getName(); + p.title = getLabel(); + p.rect = folder_rect; + p.listener = mInvFVBridgeBuilder->createBridge(LLAssetType::AT_CATEGORY, + LLAssetType::AT_CATEGORY, + LLInventoryType::IT_CATEGORY, + this, + NULL, + root_id); + p.parent_panel = this; + p.allow_multiselect = mAllowMultiSelect; + p.use_ellipses = true; // truncate inventory item text so remove horizontal scroller + mFolderRoot = (LLFolderView*)LLUICtrlFactory::create(p); } + // save current folder open state void LLPlacesInventoryPanel::saveFolderState() { diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 1023a4339b..b182c15dd0 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -420,7 +420,6 @@ BOOL LLFloaterTexturePicker::postBuild() mInventoryPanel->setFilterPermMask(mImmediateFilterPermMask); mInventoryPanel->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2)); mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - mInventoryPanel->setAllowMultiSelect(FALSE); // Disable auto selecting first filtered item because it takes away // selection from the item set by LLTextureCtrl owning this floater. -- cgit v1.2.3 From e297016af881e51c14441ac63b67257e3d8624e2 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 17 Jun 2011 15:25:37 -0700 Subject: EXP-915 FIX remove mHidden and mStartFolderID from LLFolderView* forgot a file reviewed by Leyla --- indra/newview/llplacesinventorypanel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llplacesinventorypanel.h b/indra/newview/llplacesinventorypanel.h index 6641871a0b..f647e7f970 100644 --- a/indra/newview/llplacesinventorypanel.h +++ b/indra/newview/llplacesinventorypanel.h @@ -46,7 +46,7 @@ public: LLPlacesInventoryPanel(const Params& p); ~LLPlacesInventoryPanel(); - /*virtual*/ BOOL postBuild(); + /*virtual*/ void buildFolderView(const LLInventoryPanel::Params& params); void saveFolderState(); void restoreFolderState(); -- cgit v1.2.3 From 5af57330eb23dd6f00f02bafdf08ee70b5cae50b Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 20 Jun 2011 08:57:57 -0700 Subject: EXP-917 FIX -- Inbox and Outbox options shown in the + Menu in the Inventory Panel Oops. --- .../newview/skins/default/xui/en/menu_inventory_add.xml | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'indra') diff --git a/indra/newview/skins/default/xui/en/menu_inventory_add.xml b/indra/newview/skins/default/xui/en/menu_inventory_add.xml index f38ea04858..e0ccb18c08 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory_add.xml @@ -91,22 +91,6 @@ function="Inventory.DoCreate" parameter="category" /> - - - - - - Date: Mon, 20 Jun 2011 09:28:10 -0700 Subject: ER-944: Add feature to control user sounds on a parcel. Added new checkboxes to the About Land / Sound tab. Reviewed by Kelly. --- indra/llinventory/llparcel.cpp | 23 ++++++++++++++---- indra/llinventory/llparcel.h | 19 ++++++++++----- indra/llmessage/message_prehash.cpp | 2 ++ indra/llmessage/message_prehash.h | 2 ++ indra/newview/llfloaterland.cpp | 2 +- indra/newview/llpanellandaudio.cpp | 22 +++++++++++++++++ indra/newview/llpanellandaudio.h | 2 ++ .../skins/default/xui/en/floater_about_land.xml | 28 ++++++++++++++++++++++ 8 files changed, 88 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index b388d34580..e026ad32f9 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -227,8 +227,10 @@ void LLParcel::init(const LLUUID &owner_id, setPreviousOwnerID(LLUUID::null); setPreviouslyGroupOwned(FALSE); - setHiddenAVs(false); - setHaveHiddenAVsData(false); + setHiddenAVs(FALSE); + setAllowGroupAVSounds(TRUE); + setAllowAnyAVSounds(TRUE); + setHaveNewParcelLimitData(FALSE); } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) @@ -706,6 +708,8 @@ void LLParcel::packMessage(LLSD& msg) msg["user_look_at"] = ll_sd_from_vector3(mUserLookAt); msg["landing_type"] = (U8)mLandingType; msg["hidden_avs"] = (LLSD::Boolean) getHiddenAVs(); + msg["group_av_sounds"] = (LLSD::Boolean) getAllowGroupAVSounds(); + msg["any_av_sounds"] = (LLSD::Boolean) getAllowAnyAVSounds(); } @@ -725,13 +729,22 @@ void LLParcel::unpackMessage(LLMessageSystem* msg) setMediaURL(buffer); BOOL hidden_avs = FALSE; - bool have_hidden_av_data = (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_HiddenAVs) > 0); - if (have_hidden_av_data) + BOOL any_av_sounds = TRUE; + BOOL group_av_sounds = TRUE; + bool have_new_parcel_limit_data = (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_HiddenAVs) > 0); // New version of server should send all 3 of these values + have_new_parcel_limit_data &= (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_AnyAVSounds) > 0); + have_new_parcel_limit_data &= (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_GroupAVSounds) > 0); + if (have_new_parcel_limit_data) { msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_HiddenAVs, hidden_avs); + msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_AnyAVSounds, any_av_sounds); + msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_GroupAVSounds, group_av_sounds); } setHiddenAVs((bool) hidden_avs); - setHaveHiddenAVsData(have_hidden_av_data); + setAllowAnyAVSounds((bool) any_av_sounds); + setAllowGroupAVSounds((bool) group_av_sounds); + + setHaveNewParcelLimitData(have_new_parcel_limit_data); // non-optimized version msg->getU8 ( "ParcelData", "MediaAutoScale", mMediaAutoScale ); diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index e785dba91b..c27e5a5091 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -271,8 +271,8 @@ public: void setUserLocation(const LLVector3& pos) { mUserLocation = pos; } void setUserLookAt(const LLVector3& rot) { mUserLookAt = rot; } void setLandingType(const ELandingType type) { mLandingType = type; } - void setHiddenAVs(bool hidden_avs) { mHiddenAVs = hidden_avs; } - void setHaveHiddenAVsData(bool have_hidden_av_data) { mHaveHiddenAVData = have_hidden_av_data; } // Remove this once hidden AV feature is fully available grid-wide + void setHiddenAVs(BOOL hidden_avs) { mHiddenAVs = hidden_avs; } + void setHaveNewParcelLimitData(bool have_new_parcel_data) { mHaveNewParcelLimitData = have_new_parcel_data; } // Remove this once hidden AV feature is fully available grid-wide void setAuctionID(U32 auction_id) { mAuctionID = auction_id;} @@ -299,6 +299,8 @@ public: void setDenyAnonymous(BOOL b) { setParcelFlag(PF_DENY_ANONYMOUS, b); } void setDenyAgeUnverified(BOOL b) { setParcelFlag(PF_DENY_AGEUNVERIFIED, b); } void setRestrictPushObject(BOOL b) { setParcelFlag(PF_RESTRICT_PUSHOBJECT, b); } + void setAllowGroupAVSounds(BOOL b) { mAllowGroupAVSounds = b; } + void setAllowAnyAVSounds(BOOL b) { mAllowAnyAVSounds = b; } void setDrawDistance(F32 dist) { mDrawDistance = dist; } void setSalePrice(S32 price) { mSalePrice = price; } @@ -375,8 +377,8 @@ public: const LLVector3& getUserLocation() const { return mUserLocation; } const LLVector3& getUserLookAt() const { return mUserLookAt; } ELandingType getLandingType() const { return mLandingType; } - bool getHiddenAVs() const { return mHiddenAVs; } - bool getHaveHiddenAVsData() const { return mHaveHiddenAVData; } + BOOL getHiddenAVs() const { return mHiddenAVs; } + BOOL getHaveNewParcelLimitData() const { return mHaveNewParcelLimitData; } // User-specified snapshot const LLUUID& getSnapshotID() const { return mSnapshotID; } @@ -506,6 +508,9 @@ public: BOOL getRegionDenyAgeUnverifiedOverride() const { return mRegionDenyAgeUnverifiedOverride; } + BOOL getAllowGroupAVSounds() const { return mAllowGroupAVSounds; } + BOOL getAllowAnyAVSounds() const { return mAllowAnyAVSounds; } + F32 getDrawDistance() const { return mDrawDistance; } S32 getSalePrice() const { return mSalePrice; } time_t getClaimDate() const { return mClaimDate; } @@ -616,8 +621,8 @@ protected: LLVector3 mUserLocation; LLVector3 mUserLookAt; ELandingType mLandingType; - bool mHiddenAVs; // Avatars are hidden on this parcel from outside it - bool mHaveHiddenAVData; // Remove once hidden AV feature is grid-wide + BOOL mHiddenAVs; // Avatars are hidden on this parcel from outside it + BOOL mHaveNewParcelLimitData; // Remove once hidden AV feature is grid-wide LLTimer mSaleTimerExpires; LLTimer mMediaResetTimer; @@ -673,6 +678,8 @@ protected: BOOL mRegionPushOverride; BOOL mRegionDenyAnonymousOverride; BOOL mRegionDenyAgeUnverifiedOverride; + BOOL mAllowGroupAVSounds; + BOOL mAllowAnyAVSounds; ParcelQuota mQuota; diff --git a/indra/llmessage/message_prehash.cpp b/indra/llmessage/message_prehash.cpp index 1248436f16..f7615b5ccb 100644 --- a/indra/llmessage/message_prehash.cpp +++ b/indra/llmessage/message_prehash.cpp @@ -1376,3 +1376,5 @@ char const* const _PREHASH_FaceIndex = LLMessageStringTable::getInstance()->getS char const* const _PREHASH_StatusData = LLMessageStringTable::getInstance()->getString("StatusData"); char const* const _PREHASH_ProductSKU = LLMessageStringTable::getInstance()->getString("ProductSKU"); char const* const _PREHASH_HiddenAVs = LLMessageStringTable::getInstance()->getString("HiddenAVs"); +char const* const _PREHASH_AnyAVSounds = LLMessageStringTable::getInstance()->getString("AnyAVSounds"); +char const* const _PREHASH_GroupAVSounds = LLMessageStringTable::getInstance()->getString("GroupAVSounds"); diff --git a/indra/llmessage/message_prehash.h b/indra/llmessage/message_prehash.h index f871caa3df..44c7440436 100644 --- a/indra/llmessage/message_prehash.h +++ b/indra/llmessage/message_prehash.h @@ -1376,4 +1376,6 @@ extern char const* const _PREHASH_FaceIndex; extern char const* const _PREHASH_StatusData; extern char const* const _PREHASH_ProductSKU; extern char const* const _PREHASH_HiddenAVs; +extern char const* const _PREHASH_AnyAVSounds; +extern char const* const _PREHASH_GroupAVSounds; #endif diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 0300867363..420a2b0f72 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -2036,7 +2036,7 @@ void LLPanelLandOptions::refresh() mPrivateParcelCtrl->set(parcel->getHiddenAVs()); mPrivateParcelCtrl->setLabel(getString("hidden_avs_text")); - mPrivateParcelCtrl->setEnabled(can_change_options && parcel->getHaveHiddenAVsData()); + mPrivateParcelCtrl->setEnabled(can_change_options && parcel->getHaveNewParcelLimitData()); BOOL can_change_landing_point = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_SET_LANDING_POINT); diff --git a/indra/newview/llpanellandaudio.cpp b/indra/newview/llpanellandaudio.cpp index f9730d9b71..e7bdc51b4a 100644 --- a/indra/newview/llpanellandaudio.cpp +++ b/indra/newview/llpanellandaudio.cpp @@ -91,6 +91,12 @@ BOOL LLPanelLandAudio::postBuild() mMusicURLEdit = getChild("music_url"); childSetCommitCallback("music_url", onCommitAny, this); + mCheckAVSoundAny = getChild("all av sound check"); + childSetCommitCallback("all av sound check", onCommitAny, this); + + mCheckAVSoundGroup = getChild("group av sound check"); + childSetCommitCallback("group av sound check", onCommitAny, this); + return TRUE; } @@ -144,6 +150,13 @@ void LLPanelLandAudio::refresh() mMusicURLEdit->setText(parcel->getMusicURL()); mMusicURLEdit->setEnabled( can_change_media ); + + BOOL can_change_av_sounds = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS) && parcel->getHaveNewParcelLimitData(); + mCheckAVSoundAny->set(parcel->getAllowAnyAVSounds()); + mCheckAVSoundAny->setEnabled(can_change_av_sounds); + + mCheckAVSoundGroup->set(parcel->getAllowGroupAVSounds() || parcel->getAllowAnyAVSounds()); // On if "Everyone" is on + mCheckAVSoundGroup->setEnabled(can_change_av_sounds && !parcel->getAllowAnyAVSounds()); // Enabled if "Everyone" is off } } // static @@ -164,6 +177,13 @@ void LLPanelLandAudio::onCommitAny(LLUICtrl*, void *userdata) BOOL voice_enabled = self->mCheckParcelEnableVoice->get(); BOOL voice_estate_chan = !self->mCheckParcelVoiceLocal->get(); + BOOL any_av_sound = self->mCheckAVSoundAny->get(); + BOOL group_av_sound = TRUE; // If set to "Everyone" then group is checked as well + if (!any_av_sound) + { // If "Everyone" is off, use the value from the checkbox + group_av_sound = self->mCheckAVSoundGroup->get(); + } + // Remove leading/trailing whitespace (common when copying/pasting) LLStringUtil::trim(music_url); @@ -172,6 +192,8 @@ void LLPanelLandAudio::onCommitAny(LLUICtrl*, void *userdata) parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan); parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local); parcel->setMusicURL(music_url); + parcel->setAllowAnyAVSounds(any_av_sound); + parcel->setAllowGroupAVSounds(group_av_sound); // Send current parcel data upstream to server LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); diff --git a/indra/newview/llpanellandaudio.h b/indra/newview/llpanellandaudio.h index 4b0953bdc1..32a45100f4 100644 --- a/indra/newview/llpanellandaudio.h +++ b/indra/newview/llpanellandaudio.h @@ -52,6 +52,8 @@ private: LLCheckBoxCtrl* mCheckParcelVoiceLocal; LLLineEditor* mMusicURLEdit; LLCheckBoxCtrl* mMusicUrlCheck; + LLCheckBoxCtrl* mCheckAVSoundAny; + LLCheckBoxCtrl* mCheckAVSoundGroup; LLSafeHandle& mParcel; }; diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 4ad42ea5bf..612d2a3bfe 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -1858,6 +1858,34 @@ Only large parcels can be listed in search. name="check sound local" left_pad="0" width="292" /> + + Avatar Sounds: + + + Date: Mon, 20 Jun 2011 11:00:02 -0700 Subject: EXP-915 FIX remove mHidden and mStartFolderID from LLFolderView* removed mHidden variable --- indra/newview/llfolderviewitem.cpp | 7 +------ indra/newview/llfolderviewitem.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 904c233850..5f1d32ee5a 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -130,7 +130,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mIconOpen(p.icon_open), mIconOverlay(p.icon_overlay), mListener(p.listener), - mHidden(false), mShowLoadStatus(false) { } @@ -1058,7 +1057,7 @@ void LLFolderViewItem::draw() && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime")) || (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && root_is_loading - && (mShowLoadStatus || mHidden))) + && mShowLoadStatus)) { std::string load_string = " ( " + LLTrans::getString("LoadingData") + " ) "; font->renderUTF8(load_string, 0, right_x, y, sSearchStatusColor, @@ -1368,10 +1367,6 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) // and then item rules LLFolderViewItem::filter( filter ); } - if (mHidden) - { - setOpen(); - } } if (getRoot()->getDebugFilters()) diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index c48e568b30..7d640adf2e 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -157,7 +157,6 @@ protected: BOOL mDragAndDropTarget; BOOL mIsLoading; LLTimer mTimeSinceRequestStart; - bool mHidden; bool mShowLoadStatus; // helper function to change the selection from the root. -- cgit v1.2.3 From 4ba2a801489d59b39f0c0cd9b2fc7cc4fe396a8e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 Jun 2011 11:02:36 -0700 Subject: fixed build on mac/linux --- indra/newview/llfolderviewitem.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 5f1d32ee5a..1f53586ccc 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1171,8 +1171,6 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) mHasVisibleChildren = hasFilteredDescendants(filter_generation); - LLInventoryFilter::EFolderShow show_folder_state = getRoot()->getFilter()->getShowFolderState(); - // calculate height as a single item (without any children), and reshapes rectangle to match LLFolderViewItem::arrange( width, height, filter_generation ); -- cgit v1.2.3 From 941a360c465a902a083bbab3da176351331428b5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 Jun 2011 18:03:58 -0700 Subject: EXP-893 FIX Single order purchases not sorted with most recent item delivered at top of list reviewed by Leyla --- indra/newview/llfolderviewitem.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 57e5488a4e..85791774d7 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1985,6 +1985,13 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) item->dirtyFilter(); requestArrange(); requestSort(); + LLFolderViewFolder* parentp = getParentFolder(); + while (parentp && !parentp->getCreationDate()) + { + // parent folder doesn't have a time stamp yet, so get it from us + parentp->requestSort(); + parentp = parentp->getParentFolder(); + } return TRUE; } @@ -2004,6 +2011,13 @@ BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) // rearrange all descendants too, as our indentation level might have changed folder->requestArrange(TRUE); requestSort(); + LLFolderViewFolder* parentp = getParentFolder(); + while (parentp && !parentp->getCreationDate()) + { + // parent folder doesn't have a time stamp yet, so get it from us + parentp->requestSort(); + parentp = parentp->getParentFolder(); + } return TRUE; } -- cgit v1.2.3 From 149b160a6d544824401348e8e97a64339815d8c1 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Mon, 20 Jun 2011 18:14:26 -0700 Subject: EXP-872 Hide inbox unless applicable --- indra/newview/llsidepanelinventory.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 787ebd29c2..864637d744 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -51,6 +51,7 @@ #include "llsidepaneltaskinfo.h" #include "llstring.h" #include "lltabcontainer.h" +#include "llviewermedia.h" #include "llviewernetwork.h" #include "llweb.h" @@ -245,8 +246,13 @@ void LLSidepanelInventory::handleLoginComplete() url += "api/1/users/"; url += gAgent.getID().getString(); url += "/user_status"; + + LLSD headers = LLSD::emptyMap(); + headers["Accept"] = "*/*"; + headers["Cookie"] = LLViewerMedia::getOpenIDCookie(); + headers["User-Agent"] = LLViewerMedia::getCurrentUserAgent(); - LLHTTPClient::get(url, new LLInventoryUserStatusResponder(this)); + LLHTTPClient::get(url, new LLInventoryUserStatusResponder(this), headers); // // Track inbox and outbox folder changes -- cgit v1.2.3 From 658fdbb4df40207c67b4cfa6d911e41af9545efa Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Mon, 20 Jun 2011 18:14:36 -0700 Subject: EXP-872 Hide inbox unless applicable --- indra/newview/llviewermedia.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra') diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index a70c6f4887..180e1d5676 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -160,6 +160,8 @@ public: static void createSpareBrowserMediaSource(); static LLPluginClassMedia* getSpareBrowserMediaSource(); + + static std::string getOpenIDCookie() { return sOpenIDCookie; } private: static void setOpenIDCookie(); -- cgit v1.2.3 From 917e2d18973bd17929d589ee58b3f47a09c7157b Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 21 Jun 2011 14:16:27 -0700 Subject: EXP-895 Selecting items in Marketplace Inbox does not change focus in inventory panel away from items selected in inventory panel --- indra/newview/llfolderview.cpp | 8 +- indra/newview/llpanelmaininventory.cpp | 6 +- indra/newview/llpanelmarketplaceinbox.cpp | 426 +++++++++++++++--------------- indra/newview/llpanelmarketplaceinbox.h | 2 + indra/newview/llsidepanelinventory.h | 3 +- 5 files changed, 227 insertions(+), 218 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 3884b94b60..ba6fa18aab 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -806,13 +806,7 @@ void LLFolderView::sanitizeSelection() } else { - // nothing selected to start with, so pick "My Inventory" as best guess - new_selection = getItemByID(gInventory.getRootFolderID()); - // ... except if it's hidden from the UI. - if (new_selection && new_selection->getHidden()) - { - new_selection = NULL; - } + new_selection = NULL; } if (new_selection) diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 9f797eb147..728642e4c7 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -577,14 +577,16 @@ void LLPanelMainInventory::updateItemcountText() void LLPanelMainInventory::onFocusReceived() { - LLInventoryPanel * inbox_panel = findChild("inventory_inbox"); + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + + LLInventoryPanel * inbox_panel = sidepanel_inventory->findChild("inventory_inbox"); if (inbox_panel) { inbox_panel->clearSelection(); } - LLInventoryPanel * outbox_panel = findChild("inventory_outbox"); + LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); if (outbox_panel) { diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index eff27aa541..1962724891 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -1,208 +1,218 @@ -/** - * @file llpanelmarketplaceinbox.cpp - * @brief Panel for marketplace inbox - * -* $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llpanelmarketplaceinbox.h" - -#include "llappviewer.h" -#include "llbutton.h" -#include "llinventorypanel.h" -#include "llsidepanelinventory.h" - - -#define SUPPORTING_FRESH_ITEM_COUNT 0 - - -static LLRegisterPanelClassWrapper t_panel_marketplace_inbox("panel_marketplace_inbox"); - -const LLPanelMarketplaceInbox::Params& LLPanelMarketplaceInbox::getDefaultParams() -{ - return LLUICtrlFactory::getDefaultParams(); -} - -// protected -LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) - : LLPanel(p) - , mInventoryPanel(NULL) -{ -} - -LLPanelMarketplaceInbox::~LLPanelMarketplaceInbox() -{ -} - -// virtual -BOOL LLPanelMarketplaceInbox::postBuild() -{ - mInventoryPanel = getChild("inventory_inbox"); - - mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); - - LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceInbox::handleLoginComplete, this)); - - LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceInbox::onFocusReceived, this)); - - return TRUE; -} - -void LLPanelMarketplaceInbox::handleLoginComplete() -{ - // Set us up as the class to drive the badge value for the sidebar_inventory button - LLSideTray::getInstance()->setTabButtonBadgeDriver("sidebar_inventory", this); -} - -void LLPanelMarketplaceInbox::onFocusReceived() -{ - LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); - - if (sidepanel_inventory) - { - LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel(); - - if (inv_panel) - { - inv_panel->clearSelection(); - } - - LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); - - if (outbox_panel) - { - outbox_panel->clearSelection(); - } - } -} - -BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) -{ - *accept = ACCEPT_NO; - return TRUE; -} - -U32 LLPanelMarketplaceInbox::getFreshItemCount() const -{ - U32 fresh_item_count = 0; - - LLFolderView * root_folder = mInventoryPanel->getRootFolder(); - - const LLFolderViewFolder * inbox_folder = *(root_folder->getFoldersBegin()); - - LLFolderViewFolder::folders_t::const_iterator folders_it = inbox_folder->getFoldersBegin(); - LLFolderViewFolder::folders_t::const_iterator folders_end = inbox_folder->getFoldersEnd(); - - for (; folders_it != folders_end; ++folders_it) - { - const LLFolderViewFolder * folder = *folders_it; - - if (folder->getCreationDate() > 1500) - { - fresh_item_count++; - } - } - - return fresh_item_count; -} - -U32 LLPanelMarketplaceInbox::getTotalItemCount() const -{ - LLInventoryModel* model = mInventoryPanel->getModel(); - - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - - model->getDirectDescendentsOf(model->findCategoryUUIDForType(LLFolderType::FT_INBOX, false, false), cats, items); - - U32 item_count = 0; - - if (cats) - { - item_count += cats->size(); - } - - if (items) - { - item_count += items->size(); - } - - return item_count; -} - -std::string LLPanelMarketplaceInbox::getBadgeString() const -{ - std::string item_count_str(""); - - // If the inbox is visible, and the side panel is collapsed or expanded and not the inventory panel - if (getParent()->getVisible() && - (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory"))) - { - U32 item_count = getFreshItemCount(); - - if (item_count) - { - item_count_str = llformat("%d", item_count); - } - } - - return item_count_str; -} - -void LLPanelMarketplaceInbox::draw() -{ - U32 item_count = getTotalItemCount(); - - LLView * fresh_new_count_view = getChildView("inbox_fresh_new_count"); - - if (item_count > 0) - { - std::string item_count_str = llformat("%d", item_count); - - LLStringUtil::format_map_t args; - args["[NUM]"] = item_count_str; - getChild("inbox_btn")->setLabel(getString("InboxLabelWithArg", args)); - -#if SUPPORTING_FRESH_ITEM_COUNT - // set green text to fresh item count - U32 fresh_item_count = getFreshItemCount(); - fresh_new_count_view->setVisible((fresh_item_count > 0)); - - if (fresh_item_count > 0) - { - getChild("inbox_fresh_new_count")->setTextArg("[NUM]", llformat("%d", fresh_item_count)); - } -#else - fresh_new_count_view->setVisible(FALSE); -#endif - } - else - { - getChild("inbox_btn")->setLabel(getString("InboxLabelNoArg")); - - fresh_new_count_view->setVisible(FALSE); - } - - LLPanel::draw(); -} +/** + * @file llpanelmarketplaceinbox.cpp + * @brief Panel for marketplace inbox + * +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelmarketplaceinbox.h" + +#include "llappviewer.h" +#include "llbutton.h" +#include "llinventorypanel.h" +#include "llsidepanelinventory.h" + + +#define SUPPORTING_FRESH_ITEM_COUNT 0 + + +static LLRegisterPanelClassWrapper t_panel_marketplace_inbox("panel_marketplace_inbox"); + +const LLPanelMarketplaceInbox::Params& LLPanelMarketplaceInbox::getDefaultParams() +{ + return LLUICtrlFactory::getDefaultParams(); +} + +// protected +LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) + : LLPanel(p) + , mInventoryPanel(NULL) +{ +} + +LLPanelMarketplaceInbox::~LLPanelMarketplaceInbox() +{ +} + +// virtual +BOOL LLPanelMarketplaceInbox::postBuild() +{ + mInventoryPanel = getChild("inventory_inbox"); + + mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); + + LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceInbox::handleLoginComplete, this)); + + LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceInbox::onFocusReceived, this)); + + mInventoryPanel->setSelectCallback(boost::bind(&LLPanelMarketplaceInbox::onSelectionChange, this)); + + return TRUE; +} + +void LLPanelMarketplaceInbox::onSelectionChange() +{ + LLSidepanelInventory* sidepanel_inventory = dynamic_cast(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); + + sidepanel_inventory->updateVerbs(); +} + + +void LLPanelMarketplaceInbox::handleLoginComplete() +{ + // Set us up as the class to drive the badge value for the sidebar_inventory button + LLSideTray::getInstance()->setTabButtonBadgeDriver("sidebar_inventory", this); +} + +void LLPanelMarketplaceInbox::onFocusReceived() +{ + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + + if (sidepanel_inventory) + { + LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel(); + + if (inv_panel) + { + inv_panel->clearSelection(); + } + + LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); + + if (outbox_panel) + { + outbox_panel->clearSelection(); + } + } +} + +BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) +{ + *accept = ACCEPT_NO; + return TRUE; +} + +U32 LLPanelMarketplaceInbox::getFreshItemCount() const +{ + U32 fresh_item_count = 0; + + LLFolderView * root_folder = mInventoryPanel->getRootFolder(); + + const LLFolderViewFolder * inbox_folder = *(root_folder->getFoldersBegin()); + + LLFolderViewFolder::folders_t::const_iterator folders_it = inbox_folder->getFoldersBegin(); + LLFolderViewFolder::folders_t::const_iterator folders_end = inbox_folder->getFoldersEnd(); + + for (; folders_it != folders_end; ++folders_it) + { + const LLFolderViewFolder * folder = *folders_it; + + if (folder->getCreationDate() > 1500) + { + fresh_item_count++; + } + } + + return fresh_item_count; +} + +U32 LLPanelMarketplaceInbox::getTotalItemCount() const +{ + LLInventoryModel* model = mInventoryPanel->getModel(); + + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + + model->getDirectDescendentsOf(model->findCategoryUUIDForType(LLFolderType::FT_INBOX, false, false), cats, items); + + U32 item_count = 0; + + if (cats) + { + item_count += cats->size(); + } + + if (items) + { + item_count += items->size(); + } + + return item_count; +} + +std::string LLPanelMarketplaceInbox::getBadgeString() const +{ + std::string item_count_str(""); + + // If the inbox is visible, and the side panel is collapsed or expanded and not the inventory panel + if (getParent()->getVisible() && + (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory"))) + { + U32 item_count = getFreshItemCount(); + + if (item_count) + { + item_count_str = llformat("%d", item_count); + } + } + + return item_count_str; +} + +void LLPanelMarketplaceInbox::draw() +{ + U32 item_count = getTotalItemCount(); + + LLView * fresh_new_count_view = getChildView("inbox_fresh_new_count"); + + if (item_count > 0) + { + std::string item_count_str = llformat("%d", item_count); + + LLStringUtil::format_map_t args; + args["[NUM]"] = item_count_str; + getChild("inbox_btn")->setLabel(getString("InboxLabelWithArg", args)); + +#if SUPPORTING_FRESH_ITEM_COUNT + // set green text to fresh item count + U32 fresh_item_count = getFreshItemCount(); + fresh_new_count_view->setVisible((fresh_item_count > 0)); + + if (fresh_item_count > 0) + { + getChild("inbox_fresh_new_count")->setTextArg("[NUM]", llformat("%d", fresh_item_count)); + } +#else + fresh_new_count_view->setVisible(FALSE); +#endif + } + else + { + getChild("inbox_btn")->setLabel(getString("InboxLabelNoArg")); + + fresh_new_count_view->setVisible(FALSE); + } + + LLPanel::draw(); +} diff --git a/indra/newview/llpanelmarketplaceinbox.h b/indra/newview/llpanelmarketplaceinbox.h index d5b216b56d..b176d57d3f 100644 --- a/indra/newview/llpanelmarketplaceinbox.h +++ b/indra/newview/llpanelmarketplaceinbox.h @@ -63,6 +63,8 @@ public: private: void handleLoginComplete(); + void onSelectionChange(); + void onFocusReceived(); private: diff --git a/indra/newview/llsidepanelinventory.h b/indra/newview/llsidepanelinventory.h index b68abd65cc..df29cbceba 100644 --- a/indra/newview/llsidepanelinventory.h +++ b/indra/newview/llsidepanelinventory.h @@ -70,6 +70,8 @@ public: bool isInboxEnabled() const { return mInboxEnabled; } bool isOutboxEnabled() const { return mOutboxEnabled; } + void updateVerbs(); + protected: // Tracks highlighted (selected) item in inventory panel. LLInventoryItem *getSelectedItem(); @@ -77,7 +79,6 @@ protected: void onSelectionChange(const std::deque &items, BOOL user_action); // "wear", "teleport", etc. void performActionOnSelection(const std::string &action); - void updateVerbs(); bool canWearSelected(); // check whether selected items can be worn -- cgit v1.2.3 From 1e87fc43d7c07be618678aab6ee9f5511e593e92 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Tue, 21 Jun 2011 14:57:02 -0700 Subject: Fix for memory leak & extra inventory observers in start_new_inventory_observer. Reviewed by Richard --- indra/newview/llviewermessage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 3832be727f..766df29a81 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -937,7 +937,6 @@ protected: //one global instance to bind them LLOpenTaskOffer* gNewInventoryObserver=NULL; - class LLNewInventoryHintObserver : public LLInventoryAddedObserver { protected: @@ -947,6 +946,8 @@ protected: } }; +LLNewInventoryHintObserver* gNewInventoryHintObserver=NULL; + void start_new_inventory_observer() { if (!gNewInventoryObserver) //task offer observer @@ -963,7 +964,12 @@ void start_new_inventory_observer() gInventory.addObserver(gInventoryMoveObserver); } - gInventory.addObserver(new LLNewInventoryHintObserver()); + if (!gNewInventoryHintObserver) + { + // Observer is deleted by gInventory + gNewInventoryHintObserver = new LLNewInventoryHintObserver(); + gInventory.addObserver(gNewInventoryHintObserver); + } } class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver -- cgit v1.2.3 From e2f9276a083f5883e250b0edcc5c68273985be8b Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 21 Jun 2011 15:18:05 -0700 Subject: EXP-877 Profile button not active when selecting items in Marketplace inbox --- indra/newview/llavataractions.cpp | 64 +++++++++++++++++---------- indra/newview/llavataractions.h | 3 ++ indra/newview/llsidepanelinventory.cpp | 80 ++++++++++++++++++++-------------- 3 files changed, 92 insertions(+), 55 deletions(-) (limited to 'indra') diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index cbbdcb2983..eeb4ec8458 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -69,6 +69,7 @@ #include "lltrans.h" #include "llcallingcard.h" #include "llslurl.h" // IDEVO +#include "llsidepanelinventory.h" // static void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name) @@ -444,8 +445,6 @@ void LLAvatarActions::share(const LLUUID& id) namespace action_give_inventory { - typedef std::set uuid_set_t; - /** * Returns a pointer to 'Add More' inventory panel of Edit Outfit SP. */ @@ -475,18 +474,16 @@ namespace action_give_inventory /** * Checks My Inventory visibility. */ + static bool is_give_inventory_acceptable() { - LLInventoryPanel* active_panel = get_active_inventory_panel(); - if (!active_panel) return false; - // check selection in the panel - const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); + const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); if (inventory_selected_uuids.empty()) return false; // nothing selected bool acceptable = false; - uuid_set_t::const_iterator it = inventory_selected_uuids.begin(); - const uuid_set_t::const_iterator it_end = inventory_selected_uuids.end(); + std::set::const_iterator it = inventory_selected_uuids.begin(); + const std::set::const_iterator it_end = inventory_selected_uuids.end(); for (; it != it_end; ++it) { LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it); @@ -529,12 +526,12 @@ namespace action_give_inventory } } - static void build_items_string(const uuid_set_t& inventory_selected_uuids , std::string& items_string) + static void build_items_string(const std::set& inventory_selected_uuids , std::string& items_string) { llassert(inventory_selected_uuids.size() > 0); const std::string& separator = LLTrans::getString("words_separator"); - for (uuid_set_t::const_iterator it = inventory_selected_uuids.begin(); ; ) + for (std::set::const_iterator it = inventory_selected_uuids.begin(); ; ) { LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it); if (NULL != inv_cat) @@ -570,10 +567,7 @@ namespace action_give_inventory return; } - LLInventoryPanel* active_panel = get_active_inventory_panel(); - if (!active_panel) return; - - const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); + const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); if (inventory_selected_uuids.empty()) { return; @@ -590,8 +584,8 @@ namespace action_give_inventory // We souldn't open IM session, just calculate session ID for logging purpose. See EXT-6710 const LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL, avatar_uuid); - uuid_set_t::const_iterator it = inventory_selected_uuids.begin(); - const uuid_set_t::const_iterator it_end = inventory_selected_uuids.end(); + std::set::const_iterator it = inventory_selected_uuids.begin(); + const std::set::const_iterator it_end = inventory_selected_uuids.end(); const std::string& separator = LLTrans::getString("words_separator"); std::string noncopy_item_names; @@ -654,10 +648,7 @@ namespace action_give_inventory { llassert(avatar_names.size() == avatar_uuids.size()); - LLInventoryPanel* active_panel = get_active_inventory_panel(); - if (!active_panel) return; - - const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); + const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); if (inventory_selected_uuids.empty()) { return; @@ -678,6 +669,33 @@ namespace action_give_inventory } } + + +//static +std::set LLAvatarActions::getInventorySelectedUUIDs() +{ + std::set inventory_selected_uuids; + + LLInventoryPanel* active_panel = action_give_inventory::get_active_inventory_panel(); + if (active_panel) + { + inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); + } + + if (inventory_selected_uuids.empty()) + { + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + LLInventoryPanel * inbox = sidepanel_inventory->findChild("inventory_inbox"); + if (inbox) + { + inventory_selected_uuids = inbox->getRootFolder()->getSelectionList(); + } + + } + + return inventory_selected_uuids; +} + //static void LLAvatarActions::shareWithAvatars() { @@ -705,12 +723,12 @@ bool LLAvatarActions::canShareSelectedItems(LLInventoryPanel* inv_panel /* = NUL // check selection in the panel LLFolderView* root_folder = inv_panel->getRootFolder(); - const uuid_set_t inventory_selected_uuids = root_folder->getSelectionList(); + const std::set inventory_selected_uuids = root_folder->getSelectionList(); if (inventory_selected_uuids.empty()) return false; // nothing selected bool can_share = true; - uuid_set_t::const_iterator it = inventory_selected_uuids.begin(); - const uuid_set_t::const_iterator it_end = inventory_selected_uuids.end(); + std::set::const_iterator it = inventory_selected_uuids.begin(); + const std::set::const_iterator it_end = inventory_selected_uuids.end(); for (; it != it_end; ++it) { LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it); diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h index 956fed7461..fbfd815f41 100644 --- a/indra/newview/llavataractions.h +++ b/indra/newview/llavataractions.h @@ -36,6 +36,7 @@ class LLInventoryPanel; + /** * Friend-related actions (add, remove, offer teleport, etc) */ @@ -196,6 +197,8 @@ public: */ static bool canShareSelectedItems(LLInventoryPanel* inv_panel = NULL); + static std::set getInventorySelectedUUIDs(); + private: static bool callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response); static bool handleRemove(const LLSD& notification, const LLSD& response); diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 864637d744..79d68de289 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -246,11 +246,11 @@ void LLSidepanelInventory::handleLoginComplete() url += "api/1/users/"; url += gAgent.getID().getString(); url += "/user_status"; - - LLSD headers = LLSD::emptyMap(); - headers["Accept"] = "*/*"; - headers["Cookie"] = LLViewerMedia::getOpenIDCookie(); - headers["User-Agent"] = LLViewerMedia::getCurrentUserAgent(); + + LLSD headers = LLSD::emptyMap(); + headers["Accept"] = "*/*"; + headers["Cookie"] = LLViewerMedia::getOpenIDCookie(); + headers["User-Agent"] = LLViewerMedia::getCurrentUserAgent(); LLHTTPClient::get(url, new LLInventoryUserStatusResponder(this), headers); @@ -423,22 +423,24 @@ void LLSidepanelInventory::performActionOnSelection(const std::string &action) LLFolderViewItem* current_item = panel_main_inventory->getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) { - return; + LLInventoryPanel* inbox = findChild("inventory_inbox"); + if (inbox) + { + current_item = inbox->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + } } + current_item->getListener()->performAction(panel_main_inventory->getActivePanel()->getModel(), action); } void LLSidepanelInventory::onWearButtonClicked() { - LLPanelMainInventory *panel_main_inventory = mInventoryPanel->findChild("panel_main_inventory"); - if (!panel_main_inventory) - { - llassert(panel_main_inventory != NULL); - return; - } - // Get selected items set. - const std::set selected_uuids_set = panel_main_inventory->getActivePanel()->getRootFolder()->getSelectionList(); + const std::set selected_uuids_set = LLAvatarActions::getInventorySelectedUUIDs(); if (selected_uuids_set.empty()) return; // nothing selected // Convert the set to a vector. @@ -574,34 +576,29 @@ void LLSidepanelInventory::updateVerbs() bool LLSidepanelInventory::canShare() { + bool can_share = false; + LLPanelMainInventory* panel_main_inventory = mInventoryPanel->findChild("panel_main_inventory"); - if (!panel_main_inventory) - { - llwarns << "Failed to get the main inventory panel" << llendl; - return false; - } + LLInventoryPanel* inbox = findChild("inventory_inbox"); - LLInventoryPanel* active_panel = panel_main_inventory->getActivePanel(); + return ( (panel_main_inventory ? LLAvatarActions::canShareSelectedItems(panel_main_inventory->getActivePanel()) : false) + || (inbox ? LLAvatarActions::canShareSelectedItems(inbox) : false) ); + // Avoid flicker in the Recent tab while inventory is being loaded. - if (!active_panel->getRootFolder()->hasVisibleChildren()) return false; - - return LLAvatarActions::canShareSelectedItems(active_panel); + //if (!active_panel->getRootFolder()->hasVisibleChildren()) return false; } + bool LLSidepanelInventory::canWearSelected() { - LLPanelMainInventory* panel_main_inventory = - mInventoryPanel->findChild("panel_main_inventory"); - if (!panel_main_inventory) - { - llassert(panel_main_inventory != NULL); + std::set selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); + + if (selected_uuids.empty()) return false; - } - std::set selected_uuids = panel_main_inventory->getActivePanel()->getRootFolder()->getSelectionList(); for (std::set::const_iterator it = selected_uuids.begin(); it != selected_uuids.end(); ++it) @@ -618,7 +615,15 @@ LLInventoryItem *LLSidepanelInventory::getSelectedItem() LLFolderViewItem* current_item = panel_main_inventory->getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) { - return NULL; + LLInventoryPanel* inbox = findChild("inventory_inbox"); + if (inbox) + { + current_item = inbox->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return NULL; + } + } } const LLUUID &item_id = current_item->getListener()->getUUID(); LLInventoryItem *item = gInventory.getItem(item_id); @@ -627,9 +632,20 @@ LLInventoryItem *LLSidepanelInventory::getSelectedItem() U32 LLSidepanelInventory::getSelectedCount() { + int count = 0; + LLPanelMainInventory *panel_main_inventory = mInventoryPanel->findChild("panel_main_inventory"); std::set selection_list = panel_main_inventory->getActivePanel()->getRootFolder()->getSelectionList(); - return selection_list.size(); + count += selection_list.size(); + + LLInventoryPanel* inbox = findChild("inventory_inbox"); + if (inbox) + { + selection_list = inbox->getRootFolder()->getSelectionList(); + count += selection_list.size(); + } + + return count; } LLInventoryPanel *LLSidepanelInventory::getActivePanel() -- cgit v1.2.3 From 94687fd05e356499c6708c4df6e11e85d075f992 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 22 Jun 2011 18:36:03 +0300 Subject: STORM-1305 WIP UI changes in the Day Cycle Editor. - Made the floater smaller. - Removed the "Control Help" label. - Removed the view border, added a horizontal separator. - Added missing vertical line above the rightmost "12 am" label. --- .../default/xui/en/floater_edit_day_cycle.xml | 123 ++++++++++----------- 1 file changed, 57 insertions(+), 66 deletions(-) (limited to 'indra') diff --git a/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml index 2c78d51c9f..7aae966879 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml @@ -1,13 +1,13 @@ + width="705"> Create a New Day Cycle Edit Day Cycle @@ -19,16 +19,16 @@ follows="top|left|right" height="10" layout="topleft" - left="30" + left="10" name="hint" top="25" - width="700" /> + width="685" /> @@ -52,42 +52,23 @@ width="200" /> Note: if you change the name of your preset, you will be creating a new preset and the existing preset will not be changed. - - - Control Help - - Click on a tab to edit the specific sky settings and time. @@ -115,8 +96,8 @@ name="day_cycle_slider_panel" layout="topleft" left_delta="25" - top_pad="25" - width="670"> + top_pad="15" + width="660"> + | Sky Setting: @@ -456,39 +438,48 @@ top_delta="-1" value="6:00 AM" width="75"/> - - -