diff options
Diffstat (limited to 'indra')
27 files changed, 907 insertions, 846 deletions
| diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 5568a84494..2c28b7943e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3244,7 +3244,7 @@ void hide_top_view( LLView* view )  // x and y are the desired location for the popup, in the spawning_view's  // coordinate frame, NOT necessarily the mouse location  // static -void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) +void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y, S32 mouse_x, S32 mouse_y)  {  	const S32 CURSOR_HEIGHT = 22;		// Approximate "normal" cursor size  	const S32 CURSOR_WIDTH = 12; @@ -3275,12 +3275,6 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)  		}  	} -	// Save click point for detecting cursor moves before mouse-up. -	// Must be in local coords to compare with mouseUp events. -	// If the mouse doesn't move, the menu will stay open ala the Mac. -	// See also LLContextMenu::show() -	S32 mouse_x, mouse_y; -  	// Resetting scrolling position  	if (menu->isScrollable() && menu->isScrollPositionOnShowReset())  	{ @@ -3291,7 +3285,18 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)  	menu->needsArrange();  	menu->arrangeAndClear(); -	LLUI::getInstance()->getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y); +	if ((mouse_x == 0) || (mouse_y == 0)) + +	{ +		// Save click point for detecting cursor moves before mouse-up. +		// Must be in local coords to compare with mouseUp events. +		// If the mouse doesn't move, the menu will stay open ala the Mac. +		// See also LLContextMenu::show() + +		LLUI::getInstance()->getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y); +	} +	 +	  	LLMenuHolderGL::sContextMenuSpawnPos.set(mouse_x,mouse_y);  	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getRect(); diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 1f11f26192..805620bf9b 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -510,7 +510,7 @@ public:  	void createJumpKeys();  	// Show popup at a specific location, in the spawn_view's coordinate frame -	static void showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y); +	static void showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y, S32 mouse_x = 0, S32 mouse_y = 0);  	// Whether to drop shadow menu bar   	void setDropShadowed( const BOOL shadowed ); diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index d77997a928..30bc743e72 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -263,6 +263,18 @@ std::vector<std::string> LLWindow::getDynamicFallbackFontList()  #endif  } +// static +std::vector<std::string> LLWindow::getDisplaysResolutionList() +{ +#if LL_WINDOWS +	return LLWindowWin32::getDisplaysResolutionList(); +#elif LL_DARWIN +	return LLWindowMacOSX::getDisplaysResolutionList(); +#else +	return std::vector<std::string>(); +#endif +} +  #define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400)  #define UTF16_IS_LOW_SURROGATE(U)  ((U16)((U) - 0xDC00) < 0x0400)  #define UTF16_SURROGATE_PAIR_TO_UTF32(H,L) (((H) << 10) + (L) - (0xD800 << 10) - 0xDC00 + 0x00010000) diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index a05ba8cbba..bb4e534b60 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -168,6 +168,9 @@ public:  	// Get system UI size based on DPI (for 96 DPI UI size should be 1.0)  	virtual F32 getSystemUISize() { return 1.0; } + +	static std::vector<std::string> getDisplaysResolutionList(); +  protected:  	LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags);  	virtual ~LLWindow(); diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 2604a23c85..0d0607a0bb 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -41,6 +41,7 @@  #include <OpenGL/OpenGL.h>  #include <Carbon/Carbon.h>  #include <CoreServices/CoreServices.h> +#include <CoreGraphics/CGDisplayConfiguration.h>  extern BOOL gDebugWindowProc;  BOOL gHiDPISupport = TRUE; @@ -1911,6 +1912,35 @@ void LLWindowMacOSX::interruptLanguageTextInput()  	commitCurrentPreedit(mGLView);  } +std::vector<std::string> LLWindowMacOSX::getDisplaysResolutionList() +{ +	std::vector<std::string> resolution_list; +	 +	CGDirectDisplayID display_ids[10]; +	uint32_t found_displays = 0; +	CGError err = CGGetActiveDisplayList(10, display_ids, &found_displays); +	 +	if (kCGErrorSuccess != err) +	{ +		LL_WARNS() << "Couldn't get a list of active displays" << LL_ENDL; +		return std::vector<std::string>(); +	} +	 +	for (uint32_t i = 0; i < found_displays; i++) +	{ +		S32 monitor_width = CGDisplayPixelsWide(display_ids[i]); +		S32 monitor_height = CGDisplayPixelsHigh(display_ids[i]); +		 +		std::ostringstream sstream; +		sstream << monitor_width << "x" << monitor_height;; +		std::string res = sstream.str(); +		 +		resolution_list.push_back(res); +	} +	 +	return resolution_list; +} +  //static  std::vector<std::string> LLWindowMacOSX::getDynamicFallbackFontList()  { diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 24651027e8..bf45238c8d 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -114,6 +114,8 @@ public:  	/*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async);  	/*virtual*/ F32 getSystemUISize(); +	static std::vector<std::string> getDisplaysResolutionList(); +  	static std::vector<std::string> getDynamicFallbackFontList();  	// Provide native key event data diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 0b3936f8a5..3cbba59ed7 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -400,6 +400,39 @@ LLWinImm::~LLWinImm()  } +class LLMonitorInfo +{ +public: + +	std::vector<std::string> getResolutionsList() { return mResList; } + +	LLMonitorInfo() +	{ +		EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)this); +	} + +private: + +	static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData) +	{ +		int monitor_width = lprcMonitor->right - lprcMonitor->left; +		int monitor_height = lprcMonitor->bottom - lprcMonitor->top; +		 +		std::ostringstream sstream; +		sstream << monitor_width << "x" << monitor_height;; +		std::string res = sstream.str(); + +		LLMonitorInfo* pThis = reinterpret_cast<LLMonitorInfo*>(pData); +		pThis->mResList.push_back(res); + +		return TRUE; +	} + +	std::vector<std::string> mResList; +}; + +static LLMonitorInfo sMonitorInfo; +  LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,  							 const std::string& title, const std::string& name, S32 x, S32 y, S32 width,  							 S32 height, U32 flags,  @@ -4219,6 +4252,12 @@ F32 LLWindowWin32::getSystemUISize()  }  //static +std::vector<std::string> LLWindowWin32::getDisplaysResolutionList() +{  +	return sMonitorInfo.getResolutionsList(); +} + +//static  std::vector<std::string> LLWindowWin32::getDynamicFallbackFontList()  {  	// Fonts previously in getFontListSans() have moved to fonts.xml. diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 9cd16eb993..b1e8350a78 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -114,6 +114,7 @@ public:  	LLWindowCallbacks::DragNDropResult completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url ); +	static std::vector<std::string> getDisplaysResolutionList();  	static std::vector<std::string> getDynamicFallbackFontList();  	static void setDPIAwareness();  protected: diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 88667bdc11..0d204fd716 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -234,6 +234,7 @@ set(viewer_SOURCE_FILES      llfloaterconversationpreview.cpp      llfloaterdeleteprefpreset.cpp      llfloaterdestinations.cpp +    llfloatereditenvironmentbase.cpp      llfloatereditextdaycycle.cpp      llfloaterenvironmentadjust.cpp      llfloaterevent.cpp @@ -864,6 +865,7 @@ set(viewer_HEADER_FILES      llfloaterconversationpreview.h      llfloaterdeleteprefpreset.h      llfloaterdestinations.h +    llfloatereditenvironmentbase.h      llfloatereditextdaycycle.h      llfloaterenvironmentadjust.h      llfloaterevent.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c1fd09a17b..a07aae9738 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3462,6 +3462,12 @@ void LLAppViewer::writeSystemInfo()  	gDebugInfo["FirstRunThisInstall"] = gSavedSettings.getBOOL("FirstRunThisInstall");      gDebugInfo["StartupState"] = LLStartUp::getStartupStateString(); +	std::vector<std::string> resolutions = gViewerWindow->getWindow()->getDisplaysResolutionList(); +	for (auto res_iter : resolutions) +	{ +		gDebugInfo["DisplayInfo"].append(res_iter); +	} +  	writeDebugInfo(); // Save out debug_info.log early, in case of crash.  } diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 17952349dc..711b3c61e5 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -384,6 +384,8 @@ LLFavoritesBarCtrl::LLFavoritesBarCtrl(const LLFavoritesBarCtrl::Params& p)  	mUpdateDropDownItems(true),  	mRestoreOverflowMenu(false),  	mGetPrevItems(true), +	mMouseX(0), +	mMouseY(0),  	mItemsChangedTimer()  {  	// Register callback for menus with current registrar (will be parent panel's registrar) @@ -399,7 +401,7 @@ LLFavoritesBarCtrl::LLFavoritesBarCtrl(const LLFavoritesBarCtrl::Params& p)  	//make chevron button                                                                                                                                 	LLTextBox::Params more_button_params(p.more_button);  	mMoreTextBox = LLUICtrlFactory::create<LLTextBox> (more_button_params); -	mMoreTextBox->setClickedCallback(boost::bind(&LLFavoritesBarCtrl::showDropDownMenu, this)); +	mMoreTextBox->setClickedCallback(boost::bind(&LLFavoritesBarCtrl::onMoreTextBoxClicked, this));  	addChild(mMoreTextBox);  	mDropDownItemsCount = 0; @@ -975,6 +977,12 @@ BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &it  	return TRUE;  } +void LLFavoritesBarCtrl::onMoreTextBoxClicked() +{ +	LLUI::getInstance()->getMousePositionScreen(&mMouseX, &mMouseY); +	showDropDownMenu(); +} +  void LLFavoritesBarCtrl::showDropDownMenu()  {  	if (mOverflowMenuHandle.isDead()) @@ -1130,7 +1138,7 @@ void LLFavoritesBarCtrl::positionAndShowMenu(LLToggleableMenu* menu)  		}  	} -	LLMenuGL::showPopup(this, menu, menu_x, menu_y); +	LLMenuGL::showPopup(this, menu, menu_x, menu_y, mMouseX, mMouseY);  }  void LLFavoritesBarCtrl::onButtonClick(LLUUID item_id) diff --git a/indra/newview/llfavoritesbar.h b/indra/newview/llfavoritesbar.h index d93161fd7a..2951b5cedf 100644 --- a/indra/newview/llfavoritesbar.h +++ b/indra/newview/llfavoritesbar.h @@ -96,6 +96,8 @@ protected:  	void showDropDownMenu(); +	void onMoreTextBoxClicked(); +  	LLHandle<LLView> mOverflowMenuHandle;  	LLHandle<LLView> mContextMenuHandle; @@ -163,6 +165,9 @@ private:  	BOOL mTabsHighlightEnabled; +	S32 mMouseX; +	S32 mMouseY; +  	boost::signals2::connection mEndDragConnection;  }; diff --git a/indra/newview/llfloatereditenvironmentbase.cpp b/indra/newview/llfloatereditenvironmentbase.cpp new file mode 100644 index 0000000000..2a38f18b73 --- /dev/null +++ b/indra/newview/llfloatereditenvironmentbase.cpp @@ -0,0 +1,479 @@ +/**  + * @file llfloatereditenvironmentbase.cpp + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $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 "llfloatereditenvironmentbase.h" + +#include <boost/make_shared.hpp> + +// libs +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llfilepicker.h" +#include "llsettingspicker.h" +#include "llviewerparcelmgr.h" + +// newview +#include "llsettingssky.h" +#include "llsettingswater.h" + +#include "llenvironment.h" +#include "llagent.h" +#include "llparcel.h" + +#include "llsettingsvo.h" +#include "llinventorymodel.h" + +namespace +{ +    const std::string ACTION_APPLY_LOCAL("apply_local"); +    const std::string ACTION_APPLY_PARCEL("apply_parcel"); +    const std::string ACTION_APPLY_REGION("apply_region"); +} + +//========================================================================= +const std::string LLFloaterEditEnvironmentBase::KEY_INVENTORY_ID("inventory_id"); + + +//========================================================================= + +class LLFixedSettingCopiedCallback : public LLInventoryCallback +{ +public: +    LLFixedSettingCopiedCallback(LLHandle<LLFloater> handle) : mHandle(handle) {} + +    virtual void fire(const LLUUID& inv_item_id) +    { +        if (!mHandle.isDead()) +        { +            LLViewerInventoryItem* item = gInventory.getItem(inv_item_id); +            if (item) +            { +                LLFloaterEditEnvironmentBase* floater = (LLFloaterEditEnvironmentBase*)mHandle.get(); +                floater->onInventoryCreated(item->getAssetUUID(), inv_item_id); +            } +        } +    } + +private: +    LLHandle<LLFloater> mHandle; +}; + +//========================================================================= +LLFloaterEditEnvironmentBase::LLFloaterEditEnvironmentBase(const LLSD &key) : +    LLFloater(key), +    mInventoryId(), +    mInventoryItem(nullptr), +    mIsDirty(false), +    mCanCopy(false), +    mCanMod(false), +    mCanTrans(false), +    mCanSave(false) +{ +} + +LLFloaterEditEnvironmentBase::~LLFloaterEditEnvironmentBase() +{ +} + +void LLFloaterEditEnvironmentBase::onFocusReceived() +{ +    if (isInVisibleChain()) +    { +        updateEditEnvironment(); +        LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); +    } +} + +void LLFloaterEditEnvironmentBase::onFocusLost() +{ +} + +void LLFloaterEditEnvironmentBase::loadInventoryItem(const LLUUID  &inventoryId, bool can_trans) +{ +    if (inventoryId.isNull()) +    { +        mInventoryItem = nullptr; +        mInventoryId.setNull(); +        mCanMod = true; +        mCanCopy = true; +        mCanTrans = true; +        return; +    } + +    mInventoryId = inventoryId; +    LL_INFOS("SETTINGS") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; +    mInventoryItem = gInventory.getItem(mInventoryId); + +    if (!mInventoryItem) +    { +        LL_WARNS("SETTINGS") << "Could not find inventory item with Id = " << mInventoryId << LL_ENDL; +        LLNotificationsUtil::add("CantFindInvItem"); +        closeFloater(); + +        mInventoryId.setNull(); +        mInventoryItem = nullptr; +        return; +    } + +    if (mInventoryItem->getAssetUUID().isNull()) +    { +        LL_WARNS("ENVIRONMENT") << "Asset ID in inventory item is NULL (" << mInventoryId << ")" << LL_ENDL; +        LLNotificationsUtil::add("UnableEditItem"); +        closeFloater(); + +        mInventoryId.setNull(); +        mInventoryItem = nullptr; +        return; +    } + +    mCanSave = true; +    mCanCopy = mInventoryItem->getPermissions().allowCopyBy(gAgent.getID()); +    mCanMod = mInventoryItem->getPermissions().allowModifyBy(gAgent.getID()); +    mCanTrans = can_trans && mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); + +    mExpectingAssetId = mInventoryItem->getAssetUUID(); +    LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), +        [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); +} + + +void LLFloaterEditEnvironmentBase::checkAndConfirmSettingsLoss(LLFloaterEditEnvironmentBase::on_confirm_fn cb) +{ +    if (isDirty()) +    { +        LLSD args(LLSDMap("TYPE", getEditSettings()->getSettingsType()) +            ("NAME", getEditSettings()->getName())); + +        // create and show confirmation textbox +        LLNotificationsUtil::add("SettingsConfirmLoss", args, LLSD(), +            [cb](const LLSD¬if, const LLSD&resp) +            { +                S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); +                if (opt == 0) +                    cb(); +            }); +    } +    else if (cb) +    { +        cb(); +    } +} + +void LLFloaterEditEnvironmentBase::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +{ +    if (asset_id != mExpectingAssetId) +    { +        LL_WARNS("ENVDAYEDIT") << "Expecting {" << mExpectingAssetId << "} got {" << asset_id << "} - throwing away." << LL_ENDL; +        return; +    } +    mExpectingAssetId.setNull(); +    clearDirtyFlag(); + +    if (!settings || status) +    { +        LLSD args; +        args["NAME"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; +        LLNotificationsUtil::add("FailedToFindSettings", args); +        closeFloater(); +        return; +    } + +    if (settings->getFlag(LLSettingsBase::FLAG_NOSAVE)) +    { +        mCanSave = false; +        mCanCopy = false; +        mCanMod = false; +        mCanTrans = false; +    } +    else +    { +        if (mInventoryItem) +            settings->setName(mInventoryItem->getName()); + +        if (mCanCopy) +            settings->clearFlag(LLSettingsBase::FLAG_NOCOPY); +        else +            settings->setFlag(LLSettingsBase::FLAG_NOCOPY); + +        if (mCanMod) +            settings->clearFlag(LLSettingsBase::FLAG_NOMOD); +        else +            settings->setFlag(LLSettingsBase::FLAG_NOMOD); + +        if (mCanTrans) +            settings->clearFlag(LLSettingsBase::FLAG_NOTRANS); +        else +            settings->setFlag(LLSettingsBase::FLAG_NOTRANS); +    } + +    setEditSettingsAndUpdate(settings); +} + +void LLFloaterEditEnvironmentBase::onButtonImport() +{ +    checkAndConfirmSettingsLoss([this](){ doImportFromDisk(); }); +} + +void LLFloaterEditEnvironmentBase::onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsBase::ptr_t &settings) +{ +    S32 option = LLNotificationsUtil::getSelectedOption(notification, response); +    if (0 == option) +    { +        std::string settings_name = response["message"].asString(); + +        LLInventoryObject::correctInventoryName(settings_name); +        if (settings_name.empty()) +        { +            // Ideally notification should disable 'OK' button if name won't fit our requirements, +            // for now either display notification, or use some default name +            settings_name = "Unnamed"; +        } + +        if (mCanMod) +        { +            doApplyCreateNewInventory(settings_name, settings); +        } +        else if (mInventoryItem) +        { +            const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); +            LLUUID parent_id = mInventoryItem->getParentUUID(); +            if (marketplacelistings_id == parent_id) +            { +                parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); +            } + +            LLPointer<LLInventoryCallback> cb = new LLFixedSettingCopiedCallback(getHandle()); +            copy_inventory_item( +                gAgent.getID(), +                mInventoryItem->getPermissions().getOwner(), +                mInventoryItem->getUUID(), +                parent_id, +                settings_name, +                cb); +        } +        else +        { +            LL_WARNS() << "Failed to copy fixed env setting" << LL_ENDL; +        } +    } +} + +void LLFloaterEditEnvironmentBase::onClickCloseBtn(bool app_quitting) +{ +    if (!app_quitting) +        checkAndConfirmSettingsLoss([this](){ closeFloater(); clearDirtyFlag(); }); +    else +        closeFloater(); +} + +void LLFloaterEditEnvironmentBase::doApplyCreateNewInventory(std::string settings_name, const LLSettingsBase::ptr_t &settings) +{ +    if (mInventoryItem) +    { +        LLUUID parent_id = mInventoryItem->getParentUUID(); +        U32 next_owner_perm = mInventoryItem->getPermissions().getMaskNextOwner(); +        LLSettingsVOBase::createInventoryItem(settings, next_owner_perm, parent_id, settings_name, +            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); +    } +    else +    { +        LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); +        // This method knows what sort of settings object to create. +        LLSettingsVOBase::createInventoryItem(settings, parent_id, settings_name, +            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); +    } +} + +void LLFloaterEditEnvironmentBase::doApplyUpdateInventory(const LLSettingsBase::ptr_t &settings) +{ +    LL_DEBUGS("ENVEDIT") << "Update inventory for " << mInventoryId << LL_ENDL; +    if (mInventoryId.isNull()) +    { +        LLSettingsVOBase::createInventoryItem(settings, gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS), std::string(), +            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); +    } +    else +    { +        LLSettingsVOBase::updateInventoryItem(settings, mInventoryId, +            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryUpdated(asset_id, inventory_id, results); }); +    } +} + +void LLFloaterEditEnvironmentBase::doApplyEnvironment(const std::string &where, const LLSettingsBase::ptr_t &settings) +{ +    U32 flags(0); + +    if (mInventoryItem) +    { +        if (!mInventoryItem->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) +            flags |= LLSettingsBase::FLAG_NOMOD; +        if (!mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) +            flags |= LLSettingsBase::FLAG_NOTRANS; +    } + +    flags |= settings->getFlags(); +    settings->setFlag(flags); + +    if (where == ACTION_APPLY_LOCAL) +    { +        settings->setName("Local"); // To distinguish and make sure there is a name. Safe, because this is a copy. +        LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, settings); +    } +    else if (where == ACTION_APPLY_PARCEL) +    { +        LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + +        if ((!parcel) || (parcel->getLocalID() == INVALID_PARCEL_ID)) +        { +            LL_WARNS("ENVIRONMENT") << "Can not identify parcel. Not applying." << LL_ENDL; +            LLNotificationsUtil::add("WLParcelApplyFail"); +            return; +        } + +        if (mInventoryItem && !isDirty()) +        { +            LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1, flags); +        } +        else if (settings->getSettingsType() == "sky") +        { +            LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsSky>(settings), -1, -1); +        } +        else if (settings->getSettingsType() == "water") +        { +            LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsWater>(settings), -1, -1); +        } +        else if (settings->getSettingsType() == "day") +        { +            LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsDay>(settings), -1, -1); +        } +    } +    else if (where == ACTION_APPLY_REGION) +    { +        if (mInventoryItem && !isDirty()) +        { +            LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1, flags); +        } +        else if (settings->getSettingsType() == "sky") +        { +            LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsSky>(settings), -1, -1); +        } +        else if (settings->getSettingsType() == "water") +        { +            LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsWater>(settings), -1, -1); +        } +        else if (settings->getSettingsType() == "day") +        { +            LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsDay>(settings), -1, -1); +        } +    } +    else +    { +        LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; +        return; +    } + +} + +void LLFloaterEditEnvironmentBase::doCloseInventoryFloater(bool quitting) +{ +    LLFloater* floaterp = mInventoryFloater.get(); + +    if (floaterp) +    { +        floaterp->closeFloater(quitting); +    } +} + +void LLFloaterEditEnvironmentBase::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ +    LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; + +    if (inventory_id.isNull() || !results["success"].asBoolean()) +    { +        LLNotificationsUtil::add("CantCreateInventory"); +        return; +    } +    onInventoryCreated(asset_id, inventory_id); +} + +void LLFloaterEditEnvironmentBase::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id) +{ +    bool can_trans = true; +    if (mInventoryItem) +    { +        LLPermissions perms = mInventoryItem->getPermissions(); + +        LLInventoryItem *created_item = gInventory.getItem(mInventoryId); + +        if (created_item) +        { +            can_trans = perms.allowOperationBy(PERM_TRANSFER, gAgent.getID()); +            created_item->setPermissions(perms); +            created_item->updateServer(false); +        } +    } + +    clearDirtyFlag(); +    setFocus(TRUE);                 // Call back the focus... +    loadInventoryItem(inventory_id, can_trans); +} + +void LLFloaterEditEnvironmentBase::onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ +    LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been updated with asset " << asset_id << " results are:" << results << LL_ENDL; + +    clearDirtyFlag(); +    if (inventory_id != mInventoryId) +    { +        loadInventoryItem(inventory_id); +    } +} + +void LLFloaterEditEnvironmentBase::onPanelDirtyFlagChanged(bool value) +{ +    if (value) +        setDirtyFlag(); +} + +//------------------------------------------------------------------------- +bool LLFloaterEditEnvironmentBase::canUseInventory() const +{ +    return LLEnvironment::instance().isInventoryEnabled(); +} + +bool LLFloaterEditEnvironmentBase::canApplyRegion() const +{ +    return gAgent.canManageEstate(); +} + +bool LLFloaterEditEnvironmentBase::canApplyParcel() const +{ +    return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); +} + +//========================================================================= diff --git a/indra/newview/llfloatereditenvironmentbase.h b/indra/newview/llfloatereditenvironmentbase.h new file mode 100644 index 0000000000..7c7cf5bdcd --- /dev/null +++ b/indra/newview/llfloatereditenvironmentbase.h @@ -0,0 +1,148 @@ +/**  + * @file llfloatereditenvironmentbase.h + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $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_FLOATEREDITENVIRONMENTBASE_H +#define LL_FLOATEREDITENVIRONMENTBASE_H + +#include "llfloater.h" +#include "llsettingsbase.h" +#include "llflyoutcombobtn.h" +#include "llinventory.h" + +#include "boost/signals2.hpp" + +class LLTabContainer; +class LLButton; +class LLLineEditor; +class LLFloaterSettingsPicker; +class LLFixedSettingCopiedCallback; + +class LLFloaterEditEnvironmentBase : public LLFloater +{ +    LOG_CLASS(LLFloaterEditEnvironmentBase); + +    friend class LLFixedSettingCopiedCallback; + +public: +    static const std::string    KEY_INVENTORY_ID; + +                            LLFloaterEditEnvironmentBase(const LLSD &key); +                            ~LLFloaterEditEnvironmentBase(); + +    virtual void            onFocusReceived()           override; +    virtual void            onFocusLost()               override; +     +    virtual LLSettingsBase::ptr_t   getEditSettings()   const = 0; + +    virtual BOOL            isDirty() const override            { return getIsDirty(); } + +protected: +    typedef std::function<void()> on_confirm_fn; + +    virtual void            setEditSettingsAndUpdate(const LLSettingsBase::ptr_t &settings) = 0; +    virtual void            updateEditEnvironment() = 0; + +    virtual LLFloaterSettingsPicker *getSettingsPicker() = 0; + +    void                    loadInventoryItem(const LLUUID  &inventoryId, bool can_trans = true); + +    void                    checkAndConfirmSettingsLoss(on_confirm_fn cb); + +    virtual void            doImportFromDisk() = 0; +    virtual void            doApplyCreateNewInventory(std::string settings_name, const LLSettingsBase::ptr_t &settings); +    virtual void            doApplyUpdateInventory(const LLSettingsBase::ptr_t &settings); +    virtual void            doApplyEnvironment(const std::string &where, const LLSettingsBase::ptr_t &settings); +    void                    doCloseInventoryFloater(bool quitting = false); + +    bool                    canUseInventory() const; +    bool                    canApplyRegion() const; +    bool                    canApplyParcel() const; + +    LLUUID                  mInventoryId; +    LLInventoryItem *       mInventoryItem; +    LLHandle<LLFloater>     mInventoryFloater; +    bool                    mCanCopy; +    bool                    mCanMod; +    bool                    mCanTrans; +    bool                    mCanSave; + +    bool                    mIsDirty; + +    void                    onInventoryCreated(LLUUID asset_id, LLUUID inventory_id); +    void                    onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results); +    void                    onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + +    bool                    getIsDirty() const  { return mIsDirty; } +    void                    setDirtyFlag()      { mIsDirty = true; } +    virtual void            clearDirtyFlag() = 0; + +    void                    onPanelDirtyFlagChanged(bool); + +    virtual void            onClickCloseBtn(bool app_quitting = false) override; +    void                    onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsBase::ptr_t &settings); +    void                    onButtonImport(); + +    void                    onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status); + +private: +    LLUUID                  mExpectingAssetId; // for asset load confirmation +}; + +class LLSettingsEditPanel : public LLPanel +{ +public: +    virtual void setSettings(const LLSettingsBase::ptr_t &) = 0; + +    typedef boost::signals2::signal<void(LLPanel *, bool)> on_dirty_charged_sg; +    typedef boost::signals2::connection connection_t; + +    inline bool         getIsDirty() const      { return mIsDirty; } +    inline void         setIsDirty()            { mIsDirty = true; if (!mOnDirtyChanged.empty()) mOnDirtyChanged(this, mIsDirty); } +    inline void         clearIsDirty()          { mIsDirty = false; if (!mOnDirtyChanged.empty()) mOnDirtyChanged(this, mIsDirty); } + +    inline bool        getCanChangeSettings() const    { return mCanEdit; } +    inline void        setCanChangeSettings(bool flag) { mCanEdit = flag; } + +    inline connection_t setOnDirtyFlagChanged(on_dirty_charged_sg::slot_type cb)    { return mOnDirtyChanged.connect(cb); } + + +protected: +    LLSettingsEditPanel() : +        LLPanel(), +        mIsDirty(false), +        mOnDirtyChanged() +    {} + +private: +    void onTextureChanged(LLUUID &inventory_item_id); + +    bool                mIsDirty; +    bool                mCanEdit; +     +    on_dirty_charged_sg mOnDirtyChanged; +}; + +#endif // LL_FLOATERENVIRONMENTBASE_H diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index ea22043de8..0501c287ad 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -125,7 +125,6 @@ namespace {  }  //========================================================================= -const std::string LLFloaterEditExtDayCycle::KEY_INVENTORY_ID("inventory_id");  const std::string LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT("edit_context");  const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length");  const std::string LLFloaterEditExtDayCycle::KEY_CANMOD("canmod"); @@ -133,7 +132,7 @@ const std::string LLFloaterEditExtDayCycle::KEY_CANMOD("canmod");  const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_INVENTORY("inventory");  const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL("parcel");  const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_REGION("region"); - +/*  //=========================================================================  class LLDaySettingCopiedCallback : public LLInventoryCallback @@ -156,12 +155,12 @@ public:  private:      LLHandle<LLFloater> mHandle; -}; +};*/  //=========================================================================  LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) : -    LLFloater(key), +    LLFloaterEditEnvironmentBase(key),      mFlyoutControl(nullptr),      mDayLength(0),      mCurrentTrack(1), @@ -170,19 +169,12 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) :      mFramesSlider(nullptr),      mCurrentTimeLabel(nullptr),      mImportButton(nullptr), -    mInventoryId(), -    mInventoryItem(nullptr),      mLoadFrame(nullptr),      mSkyBlender(),      mWaterBlender(),      mScratchSky(),      mScratchWater(),      mIsPlaying(false), -    mIsDirty(false), -    mCanSave(false), -    mCanCopy(false), -    mCanMod(false), -    mCanTrans(false),      mCloneTrack(nullptr),      mLoadTrack(nullptr),      mClearTrack(nullptr) @@ -425,19 +417,6 @@ void LLFloaterEditExtDayCycle::onClose(bool app_quitting)      }  } -void LLFloaterEditExtDayCycle::onFocusReceived() -{ -    if (isInVisibleChain()) -    { -        updateEditEnvironment(); -        LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); -    } -} - -void LLFloaterEditExtDayCycle::onFocusLost() -{ -} -  void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)  { @@ -488,6 +467,10 @@ void LLFloaterEditExtDayCycle::refresh()      LLFloater::refresh();  } +void LLFloaterEditExtDayCycle::setEditSettingsAndUpdate(const LLSettingsBase::ptr_t &settings) +{ +    setEditDayCycle(std::dynamic_pointer_cast<LLSettingsDay>(settings)); +}  void LLFloaterEditExtDayCycle::setEditDayCycle(const LLSettingsDay::ptr_t &pday)  { @@ -700,63 +683,6 @@ void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data)      }  } -void LLFloaterEditExtDayCycle::onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsDay::ptr_t &day) -{ -    S32 option = LLNotificationsUtil::getSelectedOption(notification, response); -    if (0 == option) -    { -        std::string settings_name = response["message"].asString(); - -        LLInventoryObject::correctInventoryName(settings_name); -        if (settings_name.empty()) -        { -            // Ideally notification should disable 'OK' button if name won't fit our requirements, -            // for now either display notification, or use some default name -            settings_name = "Unnamed"; -        } - -        if (mCanMod) -        { -            doApplyCreateNewInventory(day, settings_name); -        } -        else if (mInventoryItem) -        { -            const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); -            LLUUID parent_id = mInventoryItem->getParentUUID(); -            if (marketplacelistings_id == parent_id) -            { -                parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); -            } - -            LLPointer<LLInventoryCallback> cb = new LLDaySettingCopiedCallback(getHandle()); -            copy_inventory_item( -                gAgent.getID(), -                mInventoryItem->getPermissions().getOwner(), -                mInventoryItem->getUUID(), -                parent_id, -                settings_name, -                cb); -        } -        else -        { -            LL_WARNS() << "Failed to copy day setting" << LL_ENDL; -        } -    } -} - -void LLFloaterEditExtDayCycle::onClickCloseBtn(bool app_quitting /*= false*/) -{ -    if (!app_quitting) -        checkAndConfirmSettingsLoss([this](){ closeFloater(); clearDirtyFlag(); }); -    else -        closeFloater(); -} - -void LLFloaterEditExtDayCycle::onButtonImport() -{ -    checkAndConfirmSettingsLoss([this]() { doImportFromDisk(); }); -} -  void LLFloaterEditExtDayCycle::onButtonLoadFrame()  {      doOpenInventoryFloater((mCurrentTrack == LLSettingsDay::TRACK_WATER) ? LLSettingsType::ST_WATER : LLSettingsType::ST_SKY, LLUUID::null); @@ -1053,35 +979,6 @@ void LLFloaterEditExtDayCycle::onFrameSliderMouseUp(S32 x, S32 y, MASK mask)      selectFrame(sliderpos, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR);  } - -void LLFloaterEditExtDayCycle::onPanelDirtyFlagChanged(bool value) -{ -    if (value) -        setDirtyFlag(); -} - -void LLFloaterEditExtDayCycle::checkAndConfirmSettingsLoss(on_confirm_fn cb) -{ -    if (isDirty()) -    { -        LLSD args(LLSDMap("TYPE", mEditDay->getSettingsType()) -            ("NAME", mEditDay->getName())); - -        // create and show confirmation textbox -        LLNotificationsUtil::add("SettingsConfirmLoss", args, LLSD(), -            [cb](const LLSD¬if, const LLSD&resp) -            { -                S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); -                if (opt == 0) -                    cb(); -            }); -    } -    else if (cb) -    { -        cb(); -    } -} -  void LLFloaterEditExtDayCycle::onTimeSliderCallback()  {      stopPlay(); @@ -1435,106 +1332,6 @@ LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSi      return mCommitSignal.connect(cb);  } -void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID  &inventoryId, bool can_trans) -{ -    if (inventoryId.isNull()) -    { -        mInventoryItem = nullptr; -        mInventoryId.setNull(); -        mCanSave = true; -        mCanCopy = true; -        mCanMod = true; -        mCanTrans = true; -        return; -    } - -    mInventoryId = inventoryId; -    LL_INFOS("ENVDAYEDIT") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; -    mInventoryItem = gInventory.getItem(mInventoryId); - -    if (!mInventoryItem) -    { -        LL_WARNS("ENVDAYEDIT") << "Could not find inventory item with Id = " << mInventoryId << LL_ENDL; - -        LLNotificationsUtil::add("CantFindInvItem"); -        closeFloater(); -        mInventoryId.setNull(); -        mInventoryItem = nullptr; -        return; -    } - -    if (mInventoryItem->getAssetUUID().isNull()) -    { -        LL_WARNS("ENVDAYEDIT") << "Asset ID in inventory item is NULL (" << mInventoryId << ")" <<  LL_ENDL; - -        LLNotificationsUtil::add("UnableEditItem"); -        closeFloater(); - -        mInventoryId.setNull(); -        mInventoryItem = nullptr; -        return; -    } - -    mCanSave = true; -    mCanCopy = mInventoryItem->getPermissions().allowCopyBy(gAgent.getID()); -    mCanMod = mInventoryItem->getPermissions().allowModifyBy(gAgent.getID()); -    mCanTrans = can_trans && mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); - -    mExpectingAssetId = mInventoryItem->getAssetUUID(); -    LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), -        [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); -} - -void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) -{ -    if (asset_id != mExpectingAssetId) -    { -        LL_WARNS("ENVDAYEDIT") << "Expecting {" << mExpectingAssetId << "} got {" << asset_id << "} - throwing away." << LL_ENDL; -        return; -    } -    mExpectingAssetId.setNull(); -    clearDirtyFlag(); - -    if (!settings || status) -    { -        LLSD args; -        args["NAME"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; -        LLNotificationsUtil::add("FailedToFindSettings", args); -        closeFloater(); -        return; -    } - -    if (settings->getFlag(LLSettingsBase::FLAG_NOSAVE)) -    { -        mCanSave = false; -        mCanCopy = false; -        mCanMod = false; -        mCanTrans = false; -    } -    else -    { -        if (mCanCopy) -            settings->clearFlag(LLSettingsBase::FLAG_NOCOPY); -        else -            settings->setFlag(LLSettingsBase::FLAG_NOCOPY); - -        if (mCanMod) -            settings->clearFlag(LLSettingsBase::FLAG_NOMOD); -        else -            settings->setFlag(LLSettingsBase::FLAG_NOMOD); - -        if (mCanTrans) -            settings->clearFlag(LLSettingsBase::FLAG_NOTRANS); -        else -            settings->setFlag(LLSettingsBase::FLAG_NOTRANS); - -        if (mInventoryItem) -            settings->setName(mInventoryItem->getName()); -    } - -    setEditDayCycle(std::dynamic_pointer_cast<LLSettingsDay>(settings)); -} -  void LLFloaterEditExtDayCycle::updateEditEnvironment(void)  {      if (!mEditDay) @@ -1670,93 +1467,6 @@ void LLFloaterEditExtDayCycle::reblendSettings()      mWaterBlender->setPosition(position);      } -void LLFloaterEditExtDayCycle::doApplyCreateNewInventory(const LLSettingsDay::ptr_t &day, std::string settings_name) -{ -    if (mInventoryItem) -    { -        LLUUID parent_id = mInventoryItem->getParentUUID(); -        U32 next_owner_perm = mInventoryItem->getPermissions().getMaskNextOwner(); -        LLSettingsVOBase::createInventoryItem(day, next_owner_perm, parent_id, settings_name, -            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); -    } -    else -    { -        LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); -        // This method knows what sort of settings object to create. -        LLSettingsVOBase::createInventoryItem(day, parent_id, settings_name, -            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); -    } -} - -void LLFloaterEditExtDayCycle::doApplyUpdateInventory(const LLSettingsDay::ptr_t &day) -{ -    if (mInventoryId.isNull()) -        LLSettingsVOBase::createInventoryItem(day, gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS), std::string(), -                [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); -    else -        LLSettingsVOBase::updateInventoryItem(day, mInventoryId, -                [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryUpdated(asset_id, inventory_id, results); }); -} - -void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where, const LLSettingsDay::ptr_t &day) -{ -    U32 flags(0); - -    if (mInventoryItem) -    { -        if (!mInventoryItem->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) -            flags |= LLSettingsBase::FLAG_NOMOD; -        if (!mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) -            flags |= LLSettingsBase::FLAG_NOTRANS; -    } - -    flags |= day->getFlags(); -    day->setFlag(flags); - -    if (where == ACTION_APPLY_LOCAL) -    { -        day->setName("Local"); // To distinguish and make sure there is a name. Safe, because this is a copy. -        LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, day); -    } -    else if (where == ACTION_APPLY_PARCEL) -    { -        LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); - -        if ((!parcel) || (parcel->getLocalID() == INVALID_PARCEL_ID)) -        { -            LL_WARNS("ENVDAYEDIT") << "Can not identify parcel. Not applying." << LL_ENDL; -            LLNotificationsUtil::add("WLParcelApplyFail"); -            return; -        } - -        if (mInventoryItem && !isDirty()) -        { -            LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1, flags); -        } -        else -        { -            LLEnvironment::instance().updateParcel(parcel->getLocalID(), day, -1, -1); -        } -    } -    else if (where == ACTION_APPLY_REGION) -    { -        if (mInventoryItem && !isDirty()) -        { -            LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1, flags); -        } -        else -        { -            LLEnvironment::instance().updateRegion(day, -1, -1); -        } -    } -    else -    { -        LL_WARNS("ENVDAYEDIT") << "Unknown apply '" << where << "'" << LL_ENDL; -        return; -    } - -} -  void LLFloaterEditExtDayCycle::doApplyCommit(LLSettingsDay::ptr_t day)  {      if (!mCommitSignal.empty()) @@ -1793,51 +1503,6 @@ bool LLFloaterEditExtDayCycle::isAddingFrameAllowed()      return mFramesSlider->canAddSliders();  } -void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) -{ -    LL_INFOS("ENVDAYEDIT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; - -    if (inventory_id.isNull() || !results["success"].asBoolean()) -    { -        LLNotificationsUtil::add("CantCreateInventory"); -        return; -    } -    onInventoryCreated(asset_id, inventory_id); -} - -void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id) -{ -    bool can_trans = true; -    if (mInventoryItem) -    { -        LLPermissions perms = mInventoryItem->getPermissions(); - -        LLInventoryItem *created_item = gInventory.getItem(mInventoryId); -         -        if (created_item) -        { -            can_trans = perms.allowOperationBy(PERM_TRANSFER, gAgent.getID()); -            created_item->setPermissions(perms); -            created_item->updateServer(false); -        } -    } - -    clearDirtyFlag(); -    setFocus(TRUE);                 // Call back the focus... -    loadInventoryItem(inventory_id, can_trans); -} - -void LLFloaterEditExtDayCycle::onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results) -{ -    LL_WARNS("ENVDAYEDIT") << "Inventory item " << inventory_id << " has been updated with asset " << asset_id << " results are:" << results << LL_ENDL; - -    clearDirtyFlag(); -    if (inventory_id != mInventoryId) -    { -        loadInventoryItem(inventory_id); -    } -} -  void LLFloaterEditExtDayCycle::doImportFromDisk()  {   // Load a a legacy Windlight XML from disk.      (new LLFilePickerReplyThread(boost::bind(&LLFloaterEditExtDayCycle::loadSettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile(); @@ -1864,21 +1529,6 @@ void LLFloaterEditExtDayCycle::loadSettingFromFile(const std::vector<std::string      setEditDayCycle(legacyday);  } -bool LLFloaterEditExtDayCycle::canUseInventory() const -{ -    return LLEnvironment::instance().isInventoryEnabled(); -} - -bool LLFloaterEditExtDayCycle::canApplyRegion() const -{ -    return gAgent.canManageEstate(); -} - -bool LLFloaterEditExtDayCycle::canApplyParcel() const -{ -    return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); -} -  void LLFloaterEditExtDayCycle::startPlay()  {      doCloseInventoryFloater(); @@ -1983,14 +1633,8 @@ void LLFloaterEditExtDayCycle::doCloseTrackFloater(bool quitting)      }  } -void LLFloaterEditExtDayCycle::onPickerCommitTrackId(U32 track_id) +LLFloaterSettingsPicker * LLFloaterEditExtDayCycle::getSettingsPicker()  { -    cloneTrack(track_id, mCurrentTrack); -} - -void LLFloaterEditExtDayCycle::doOpenInventoryFloater(LLSettingsType::type_e type, LLUUID curritem) -{ -//  LLUI::sWindow->setCursor(UI_CURSOR_WAIT);      LLFloaterSettingsPicker *picker = static_cast<LLFloaterSettingsPicker *>(mInventoryFloater.get());      // Show the dialog @@ -2003,7 +1647,17 @@ void LLFloaterEditExtDayCycle::doOpenInventoryFloater(LLSettingsType::type_e typ          picker->setCommitCallback([this](LLUICtrl *, const LLSD &data){ onPickerCommitSetting(data["ItemId"].asUUID(), data["Track"].asInteger()); });      } +    return picker; +} + +void LLFloaterEditExtDayCycle::onPickerCommitTrackId(U32 track_id) +{ +    cloneTrack(track_id, mCurrentTrack); +} +void LLFloaterEditExtDayCycle::doOpenInventoryFloater(LLSettingsType::type_e type, LLUUID curritem) +{ +    LLFloaterSettingsPicker *picker = getSettingsPicker();      picker->setSettingsFilter(type);      picker->setSettingsItemId(curritem);      if (type == LLSettingsType::ST_DAYCYCLE) @@ -2018,16 +1672,6 @@ void LLFloaterEditExtDayCycle::doOpenInventoryFloater(LLSettingsType::type_e typ      picker->setFocus(TRUE);  } -void LLFloaterEditExtDayCycle::doCloseInventoryFloater(bool quitting) -{ -    LLFloater* floaterp = mInventoryFloater.get(); - -    if (floaterp) -    { -        floaterp->closeFloater(quitting); -    } -} -  void LLFloaterEditExtDayCycle::onPickerCommitSetting(LLUUID item_id, S32 track)  {      LLSettingsBase::TrackPosition frame(mTimeSlider->getCurSliderValue()); @@ -2118,7 +1762,9 @@ void LLFloaterEditExtDayCycle::onAssetLoadedForInsertion(LLUUID item_id, LLUUID      LLInventoryItem *inv_item = gInventory.getItem(item_id); -    if (inv_item && !inv_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) +    if (inv_item +        && (!inv_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()) +            || !inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())))      {          // Need to check if item is already no-transfer, otherwise make it no-transfer          bool no_transfer = false; diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index b6e9fdb14f..9a30fb199f 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -32,6 +32,7 @@  #include <boost/signals2.hpp>  #include "llenvironment.h" +#include "llfloatereditenvironmentbase.h"  class LLCheckBoxCtrl;  class LLComboBox; @@ -50,14 +51,13 @@ typedef std::shared_ptr<LLSettingsBase> LLSettingsBasePtr_t;  /**   * Floater for creating or editing a day cycle.   */ -class LLFloaterEditExtDayCycle : public LLFloater +class LLFloaterEditExtDayCycle : public LLFloaterEditEnvironmentBase  {  	LOG_CLASS(LLFloaterEditExtDayCycle);      friend class LLDaySettingCopiedCallback;  public: -    static const std::string    KEY_INVENTORY_ID;      static const std::string    KEY_EDIT_CONTEXT;      static const std::string    KEY_DAY_LENGTH;      static const std::string    KEY_CANMOD; @@ -82,8 +82,8 @@ public:      virtual BOOL                postBuild() override;      virtual void                onOpen(const LLSD& key) override;      virtual void                onClose(bool app_quitting) override; -    virtual void                onFocusReceived() override; -    virtual void                onFocusLost() override; +    //virtual void                onFocusReceived() override; +    //virtual void                onFocusLost() override;      virtual void                onVisibilityChange(BOOL new_visibility) override;      connection_t                setEditCommitSignal(edit_commit_signal_t::slot_type cb); @@ -97,10 +97,13 @@ public:      LLUUID                      getEditingAssetId() { return mEditDay ? mEditDay->getAssetId() : LLUUID::null; }      LLUUID                      getEditingInventoryId() { return mInventoryId; } +    virtual LLSettingsBase::ptr_t getEditSettings()   const override { return mEditDay; } +      BOOL			            handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) override; -    BOOL                        isDirty() const override { return getIsDirty(); }  +protected: +    virtual void                setEditSettingsAndUpdate(const LLSettingsBase::ptr_t &settings) override;  private:      typedef std::function<void()> on_confirm_fn; @@ -108,8 +111,8 @@ private:  	// flyout response/click  	void                        onButtonApply(LLUICtrl *ctrl, const LLSD &data); -    virtual void                onClickCloseBtn(bool app_quitting = false) override; -    void                        onButtonImport(); +    //virtual void                onClickCloseBtn(bool app_quitting = false) override; +    //void                        onButtonImport();      void                        onButtonLoadFrame();      void                        onAddFrame();  	void                        onRemoveFrame(); @@ -119,7 +122,6 @@ private:  	void                        onCommitName(class LLLineEditor* caller, void* user_data);  	void                        onTrackSelectionCallback(const LLSD& user_data);  	void                        onPlayActionCallback(const LLSD& user_data); -	void                        onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsDay::ptr_t &day);  	// time slider clicked  	void                        onTimeSliderCallback();  	// a frame moved or frame selection changed @@ -128,10 +130,6 @@ private:      void                        onFrameSliderMouseDown(S32 x, S32 y, MASK mask);      void                        onFrameSliderMouseUp(S32 x, S32 y, MASK mask); -    void                        onPanelDirtyFlagChanged(bool); - -    void                        checkAndConfirmSettingsLoss(on_confirm_fn cb); -      void                        cloneTrack(U32 source_index, U32 dest_index);      void                        cloneTrack(const LLSettingsDay::ptr_t &source_day, U32 source_index, U32 dest_index);  	void                        selectTrack(U32 track_index, bool force = false); @@ -148,25 +146,21 @@ private:      void                        removeCurrentSliderFrame();      void                        removeSliderFrame(F32 frame); -    void                        loadInventoryItem(const LLUUID  &inventoryId, bool can_trans = true); -    void                        onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); - -    void                        doImportFromDisk(); +    virtual void                doImportFromDisk() override;      void                        loadSettingFromFile(const std::vector<std::string>& filenames); -    void                        doApplyCreateNewInventory(const LLSettingsDay::ptr_t &day, std::string settings_name); -    void                        doApplyUpdateInventory(const LLSettingsDay::ptr_t &day); -    void                        doApplyEnvironment(const std::string &where, const LLSettingsDay::ptr_t &day);      void                        doApplyCommit(LLSettingsDay::ptr_t day);      void                        onInventoryCreated(LLUUID asset_id, LLUUID inventory_id);      void                        onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results);      void                        onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results); +      void                        doOpenTrackFloater(const LLSD &args);      void                        doCloseTrackFloater(bool quitting = false); +    virtual LLFloaterSettingsPicker* getSettingsPicker() override;      void                        onPickerCommitTrackId(U32 track_id);      void                        doOpenInventoryFloater(LLSettingsType::type_e type, LLUUID curritem); -    void                        doCloseInventoryFloater(bool quitting = false); +    //void                        doCloseInventoryFloater(bool quitting = false);      void                        onPickerCommitSetting(LLUUID item_id, S32 track);      void                        onAssetLoadedForInsertion(LLUUID item_id,                                                            LLUUID asset_id, @@ -176,11 +170,7 @@ private:                                                            S32 dest_track,                                                            LLSettingsBase::TrackPosition dest_frame); -    bool                        canUseInventory() const; -    bool                        canApplyRegion() const; -    bool                        canApplyParcel() const; - -    void                        updateEditEnvironment(); +    virtual void                updateEditEnvironment() override;      void                        synchronizeTabs();      void                        reblendSettings(); @@ -193,7 +183,7 @@ private:      bool                        getIsDirty() const  { return mIsDirty; }      void                        setDirtyFlag()      { mIsDirty = true; } -    virtual void                clearDirtyFlag(); +    virtual void                clearDirtyFlag() override;      bool                        isRemovingFrameAllowed();      bool                        isAddingFrameAllowed(); @@ -218,11 +208,8 @@ private:      LLView*                     mSkyTabLayoutContainer;      LLView*                     mWaterTabLayoutContainer;      LLTextBox*                  mCurrentTimeLabel; -    LLUUID                      mInventoryId; -    LLInventoryItem *           mInventoryItem;      LLFlyoutComboBtnCtrl *      mFlyoutControl; -    LLHandle<LLFloater>         mInventoryFloater;      LLHandle<LLFloater>         mTrackFloater;      LLTrackBlenderLoopingManual::ptr_t  mSkyBlender; @@ -236,11 +223,6 @@ private:      LLFrameTimer                mPlayTimer;      F32                         mPlayStartFrame; // an env frame      bool                        mIsPlaying; -    bool                        mIsDirty; -    bool                        mCanCopy; -    bool                        mCanMod; -    bool                        mCanTrans; -    bool                        mCanSave;      edit_commit_signal_t        mCommitSignal; diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 37e162b249..41bbd5e8f9 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -81,44 +81,11 @@ namespace      const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml");  } -//========================================================================= -const std::string LLFloaterFixedEnvironment::KEY_INVENTORY_ID("inventory_id"); - - -//========================================================================= - -class LLFixedSettingCopiedCallback : public LLInventoryCallback -{ -public: -    LLFixedSettingCopiedCallback(LLHandle<LLFloater> handle) : mHandle(handle) {} - -    virtual void fire(const LLUUID& inv_item_id) -    { -        if (!mHandle.isDead()) -        { -            LLViewerInventoryItem* item = gInventory.getItem(inv_item_id); -            if (item) -            { -                LLFloaterFixedEnvironment* floater = (LLFloaterFixedEnvironment*)mHandle.get(); -                floater->onInventoryCreated(item->getAssetUUID(), inv_item_id); -            } -        } -    } - -private: -    LLHandle<LLFloater> mHandle; -};  //=========================================================================  LLFloaterFixedEnvironment::LLFloaterFixedEnvironment(const LLSD &key) : -    LLFloater(key), -    mFlyoutControl(nullptr), -    mInventoryId(), -    mInventoryItem(nullptr), -    mIsDirty(false), -    mCanCopy(false), -    mCanMod(false), -    mCanTrans(false) +    LLFloaterEditEnvironmentBase(key), +    mFlyoutControl(nullptr)  {  } @@ -176,19 +143,6 @@ void LLFloaterFixedEnvironment::onClose(bool app_quitting)      syncronizeTabs();  } -void LLFloaterFixedEnvironment::onFocusReceived() -{ -    if (isInVisibleChain()) -    { -        updateEditEnvironment(); -        LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); -    } -} - -void LLFloaterFixedEnvironment::onFocusLost() -{ -} -  void LLFloaterFixedEnvironment::refresh()  {      if (!mSettings) @@ -220,6 +174,15 @@ void LLFloaterFixedEnvironment::refresh()      }  } +void LLFloaterFixedEnvironment::setEditSettingsAndUpdate(const LLSettingsBase::ptr_t &settings) +{ +    mSettings = settings; // shouldn't this do buildDeepCloneAndUncompress() ? +    updateEditEnvironment(); +    syncronizeTabs(); +    refresh(); +    LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST); +} +  void LLFloaterFixedEnvironment::syncronizeTabs()  {      S32 count = mTab->getTabCount(); @@ -250,131 +213,9 @@ LLFloaterSettingsPicker * LLFloaterFixedEnvironment::getSettingsPicker()      return picker;  } -void LLFloaterFixedEnvironment::loadInventoryItem(const LLUUID  &inventoryId, bool can_trans) -{ -    if (inventoryId.isNull()) -    { -        mInventoryItem = nullptr; -        mInventoryId.setNull(); -        mCanMod = true; -        mCanCopy = true; -        mCanTrans = true; -        return; -    } - -    mInventoryId = inventoryId; -    LL_INFOS("SETTINGS") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; -    mInventoryItem = gInventory.getItem(mInventoryId); - -    if (!mInventoryItem) -    { -        LL_WARNS("SETTINGS") << "Could not find inventory item with Id = " << mInventoryId << LL_ENDL; -        LLNotificationsUtil::add("CantFindInvItem"); -        closeFloater(); - -        mInventoryId.setNull(); -        mInventoryItem = nullptr; -        return; -    } - -    if (mInventoryItem->getAssetUUID().isNull()) -    { -        LL_WARNS("ENVIRONMENT") << "Asset ID in inventory item is NULL (" << mInventoryId << ")" << LL_ENDL; -        LLNotificationsUtil::add("UnableEditItem"); -        closeFloater(); - -        mInventoryId.setNull(); -        mInventoryItem = nullptr; -        return; -    } - -    mCanCopy = mInventoryItem->getPermissions().allowCopyBy(gAgent.getID()); -    mCanMod = mInventoryItem->getPermissions().allowModifyBy(gAgent.getID()); -    mCanTrans = can_trans && mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); - -    LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), -        [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); -} - - -void LLFloaterFixedEnvironment::checkAndConfirmSettingsLoss(LLFloaterFixedEnvironment::on_confirm_fn cb) -{ -    if (isDirty()) -    { -        LLSD args(LLSDMap("TYPE", mSettings->getSettingsType()) -            ("NAME", mSettings->getName())); - -        // create and show confirmation textbox -        LLNotificationsUtil::add("SettingsConfirmLoss", args, LLSD(), -            [cb](const LLSD¬if, const LLSD&resp) -            { -                S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); -                if (opt == 0) -                    cb(); -            }); -    } -    else if (cb) -    { -        cb(); -    } -} -  void LLFloaterFixedEnvironment::onPickerCommitSetting(LLUUID item_id)  {      loadInventoryItem(item_id); -//     mInventoryId = item_id; -//     mInventoryItem = gInventory.getItem(mInventoryId); -//  -//     mCanCopy = mInventoryItem->getPermissions().allowCopyBy(gAgent.getID()); -//     mCanMod = mInventoryItem->getPermissions().allowModifyBy(gAgent.getID()); -//     mCanTrans = mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); -//  -//     LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), -//         [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); -} - -void LLFloaterFixedEnvironment::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) -{ -    if (mInventoryItem && mInventoryItem->getAssetUUID() != asset_id) -    { -        LL_WARNS("ENVIRONMENT") << "Discarding obsolete asset callback" << LL_ENDL; -        return; -    } - -    clearDirtyFlag(); - -    if (!settings || status) -    { -        LLSD args; -        args["NAME"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; -        LLNotificationsUtil::add("FailedToFindSettings", args); -        closeFloater(); -        return; -    } - -    mSettings = settings; -    if (mInventoryItem) -        mSettings->setName(mInventoryItem->getName()); - -    if (mCanCopy) -        settings->clearFlag(LLSettingsBase::FLAG_NOCOPY); -    else -        settings->setFlag(LLSettingsBase::FLAG_NOCOPY); - -    if (mCanMod) -        settings->clearFlag(LLSettingsBase::FLAG_NOMOD); -    else -        settings->setFlag(LLSettingsBase::FLAG_NOMOD); - -    if (mCanTrans) -        settings->clearFlag(LLSettingsBase::FLAG_NOTRANS); -    else -        settings->setFlag(LLSettingsBase::FLAG_NOTRANS); - -    updateEditEnvironment(); -    syncronizeTabs(); -    refresh(); -    LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST);  }  void LLFloaterFixedEnvironment::onNameChanged(const std::string &name) @@ -473,50 +314,6 @@ void LLFloaterFixedEnvironment::onButtonApply(LLUICtrl *ctrl, const LLSD &data)      }  } -void LLFloaterFixedEnvironment::onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsBase::ptr_t &settings) -{ -    S32 option = LLNotificationsUtil::getSelectedOption(notification, response); -    if (0 == option) -    { -        std::string settings_name = response["message"].asString(); - -        LLInventoryObject::correctInventoryName(settings_name); -        if (settings_name.empty()) -        { -            // Ideally notification should disable 'OK' button if name won't fit our requirements, -            // for now either display notification, or use some default name -            settings_name = "Unnamed"; -        } - -        if (mCanMod) -        { -            doApplyCreateNewInventory(settings_name, settings); -        } -        else if (mInventoryItem) -        { -            const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); -            LLUUID parent_id = mInventoryItem->getParentUUID(); -            if (marketplacelistings_id == parent_id) -            { -                parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); -            } - -            LLPointer<LLInventoryCallback> cb = new LLFixedSettingCopiedCallback(getHandle()); -            copy_inventory_item( -                gAgent.getID(), -                mInventoryItem->getPermissions().getOwner(), -                mInventoryItem->getUUID(), -                parent_id, -                settings_name, -                cb); -        } -        else -        { -            LL_WARNS() << "Failed to copy fixed env setting" << LL_ENDL; -        } -    } -} -  void LLFloaterFixedEnvironment::onClickCloseBtn(bool app_quitting)  {      if (!app_quitting) @@ -530,116 +327,6 @@ void LLFloaterFixedEnvironment::onButtonLoad()      checkAndConfirmSettingsLoss([this](){ doSelectFromInventory(); });  } -void LLFloaterFixedEnvironment::doApplyCreateNewInventory(std::string settings_name, const LLSettingsBase::ptr_t &settings) -{ -    if (mInventoryItem) -    { -        LLUUID parent_id = mInventoryItem->getParentUUID(); -        U32 next_owner_perm = mInventoryItem->getPermissions().getMaskNextOwner(); -        LLSettingsVOBase::createInventoryItem(settings, next_owner_perm, parent_id, settings_name, -            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); -    } -    else -    { -        LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); -        // This method knows what sort of settings object to create. -        LLSettingsVOBase::createInventoryItem(settings, parent_id, settings_name, -            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); -    } -} - -void LLFloaterFixedEnvironment::doApplyUpdateInventory(const LLSettingsBase::ptr_t &settings) -{ -    LL_DEBUGS("ENVEDIT") << "Update inventory for " << mInventoryId << LL_ENDL; -    if (mInventoryId.isNull()) -    { -        LLSettingsVOBase::createInventoryItem(settings, gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS), std::string(), -            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); -    } -    else -    { -        LLSettingsVOBase::updateInventoryItem(settings, mInventoryId, -            [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryUpdated(asset_id, inventory_id, results); }); -    } -} - -void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where, const LLSettingsBase::ptr_t &settings) -{ -    U32 flags(0); - -    if (mInventoryItem) -    { -        if (!mInventoryItem->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) -            flags |= LLSettingsBase::FLAG_NOMOD; -        if (!mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) -            flags |= LLSettingsBase::FLAG_NOTRANS; -    } - -    flags |= settings->getFlags(); -    settings->setFlag(flags); - -    if (where == ACTION_APPLY_LOCAL) -    { -        settings->setName("Local"); // To distinguish and make sure there is a name. Safe, because this is a copy. -        LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, settings); -    } -    else if (where == ACTION_APPLY_PARCEL) -    { -        LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); - -        if ((!parcel) || (parcel->getLocalID() == INVALID_PARCEL_ID)) -        { -            LL_WARNS("ENVIRONMENT") << "Can not identify parcel. Not applying." << LL_ENDL; -            LLNotificationsUtil::add("WLParcelApplyFail"); -            return; -        } - -        if (mInventoryItem && !isDirty()) -        { -            LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1, flags); -        } -        else if (settings->getSettingsType() == "sky") -        { -            LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsSky>(settings), -1, -1); -        } -        else if (settings->getSettingsType() == "water") -        { -            LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsWater>(settings), -1, -1); -        } -    } -    else if (where == ACTION_APPLY_REGION) -    { -        if (mInventoryItem && !isDirty()) -        { -            LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1, flags); -        } -        else if (settings->getSettingsType() == "sky") -        { -            LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsSky>(settings), -1, -1); -        } -        else if (settings->getSettingsType() == "water") -        { -            LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsWater>(settings), -1, -1); -        } -    } -    else -    { -        LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; -        return; -    } - -} - -void LLFloaterFixedEnvironment::doCloseInventoryFloater(bool quitting) -{ -    LLFloater* floaterp = mInventoryFloater.get(); - -    if (floaterp) -    { -        floaterp->closeFloater(quitting); -    } -} -  void LLFloaterFixedEnvironment::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results)  {      LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; @@ -709,28 +396,6 @@ void LLFloaterFixedEnvironment::doSelectFromInventory()      picker->setFocus(TRUE);  } -void LLFloaterFixedEnvironment::onPanelDirtyFlagChanged(bool value) -{ -    if (value) -        setDirtyFlag(); -} - -//------------------------------------------------------------------------- -bool LLFloaterFixedEnvironment::canUseInventory() const -{ -    return LLEnvironment::instance().isInventoryEnabled(); -} - -bool LLFloaterFixedEnvironment::canApplyRegion() const -{ -    return gAgent.canManageEstate(); -} - -bool LLFloaterFixedEnvironment::canApplyParcel() const -{ -    return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); -} -  //=========================================================================  LLFloaterFixedEnvironmentWater::LLFloaterFixedEnvironmentWater(const LLSD &key):      LLFloaterFixedEnvironment(key) diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h index 513996c4a3..f35f4a4368 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -27,7 +27,7 @@  #ifndef LL_FLOATERFIXEDENVIRONMENT_H  #define LL_FLOATERFIXEDENVIRONMENT_H -#include "llfloater.h" +#include "llfloatereditenvironmentbase.h"  #include "llsettingsbase.h"  #include "llflyoutcombobtn.h"  #include "llinventory.h" @@ -43,15 +43,10 @@ class LLFixedSettingCopiedCallback;  /**   * Floater container for creating and editing fixed environment settings.   */ -class LLFloaterFixedEnvironment : public LLFloater +class LLFloaterFixedEnvironment : public LLFloaterEditEnvironmentBase  {      LOG_CLASS(LLFloaterFixedEnvironment); - -    friend class LLFixedSettingCopiedCallback; -  public: -    static const std::string    KEY_INVENTORY_ID; -                              LLFloaterFixedEnvironment(const LLSD &key);                              ~LLFloaterFixedEnvironment(); @@ -59,64 +54,35 @@ public:      virtual void            onOpen(const LLSD& key)     override;      virtual void            onClose(bool app_quitting)  override; -    virtual void            onFocusReceived()           override; -    virtual void            onFocusLost()               override; -      void                    setEditSettings(const LLSettingsBase::ptr_t &settings)  { mSettings = settings; clearDirtyFlag(); syncronizeTabs(); refresh(); } -    LLSettingsBase::ptr_t   getEditSettings()   const                           { return mSettings; } - -    virtual BOOL            isDirty() const override            { return getIsDirty(); } +    virtual LLSettingsBase::ptr_t getEditSettings()   const override                { return mSettings; }  protected:      typedef std::function<void()> on_confirm_fn; -    virtual void            updateEditEnvironment() = 0;      virtual void            refresh()                   override; +    void                    setEditSettingsAndUpdate(const LLSettingsBase::ptr_t &settings) override;      virtual void            syncronizeTabs(); -    LLFloaterSettingsPicker *getSettingsPicker(); - -    void                    loadInventoryItem(const LLUUID  &inventoryId, bool can_trans = true); - -    void                    checkAndConfirmSettingsLoss(on_confirm_fn cb); +    virtual LLFloaterSettingsPicker *getSettingsPicker() override;      LLTabContainer *        mTab;      LLLineEditor *          mTxtName;      LLSettingsBase::ptr_t   mSettings; -    virtual void            doImportFromDisk() = 0; -    virtual void            doApplyCreateNewInventory(std::string settings_name, const LLSettingsBase::ptr_t &settings); -    virtual void            doApplyUpdateInventory(const LLSettingsBase::ptr_t &settings); -    virtual void            doApplyEnvironment(const std::string &where, const LLSettingsBase::ptr_t &settings); -    void                    doCloseInventoryFloater(bool quitting = false); - -    bool                    canUseInventory() const; -    bool                    canApplyRegion() const; -    bool                    canApplyParcel() const; -      LLFlyoutComboBtnCtrl *      mFlyoutControl; -    LLUUID                  mInventoryId; -    LLInventoryItem *       mInventoryItem; -    LLHandle<LLFloater>     mInventoryFloater; -    bool                    mCanCopy; -    bool                    mCanMod; -    bool                    mCanTrans; -      void                    onInventoryCreated(LLUUID asset_id, LLUUID inventory_id);      void                    onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results);      void                    onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results); -    bool                    getIsDirty() const  { return mIsDirty; } -    void                    setDirtyFlag()      { mIsDirty = true; } -    virtual void            clearDirtyFlag(); +    virtual void            clearDirtyFlag() override; +    void                    updatePermissionFlags();      void                    doSelectFromInventory(); -    void                    onPanelDirtyFlagChanged(bool);      virtual void            onClickCloseBtn(bool app_quitting = false) override; -    void                    onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsBase::ptr_t &settings);  private:      void                    onNameChanged(const std::string &name); @@ -126,9 +92,6 @@ private:      void                    onButtonLoad();      void                    onPickerCommitSetting(LLUUID item_id); -    void                    onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status); - -    bool                    mIsDirty;  };  class LLFloaterFixedEnvironmentWater : public LLFloaterFixedEnvironment @@ -172,36 +135,4 @@ protected:  private:  }; -class LLSettingsEditPanel : public LLPanel -{ -public: -    virtual void setSettings(const LLSettingsBase::ptr_t &) = 0; - -    typedef boost::signals2::signal<void(LLPanel *, bool)> on_dirty_charged_sg; -    typedef boost::signals2::connection connection_t; - -    inline bool         getIsDirty() const      { return mIsDirty; } -    inline void         setIsDirty()            { mIsDirty = true; if (!mOnDirtyChanged.empty()) mOnDirtyChanged(this, mIsDirty); } -    inline void         clearIsDirty()          { mIsDirty = false; if (!mOnDirtyChanged.empty()) mOnDirtyChanged(this, mIsDirty); } - -    inline bool        getCanChangeSettings() const    { return mCanEdit; } -    inline void        setCanChangeSettings(bool flag) { mCanEdit = flag; } - -    inline connection_t setOnDirtyFlagChanged(on_dirty_charged_sg::slot_type cb)    { return mOnDirtyChanged.connect(cb); } - - -protected: -    LLSettingsEditPanel() : -        LLPanel(), -        mIsDirty(false), -        mOnDirtyChanged() -    {} - -private: -    bool                mIsDirty; -    bool                mCanEdit; -     -    on_dirty_charged_sg mOnDirtyChanged; -}; -  #endif // LL_FLOATERFIXEDENVIRONMENT_H diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index 21420b122b..540d2366a9 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -304,12 +304,15 @@ void LLFloaterIMContainer::addFloater(LLFloater* floaterp,  	LLIconCtrl* icon = 0; +	bool is_in_group = gAgent.isInGroup(session_id, TRUE); +	LLUUID icon_id; -	if(gAgent.isInGroup(session_id, TRUE)) +	if (is_in_group)  	{  		LLGroupIconCtrl::Params icon_params;  		icon_params.group_id = session_id;  		icon = LLUICtrlFactory::instance().create<LLGroupIconCtrl>(icon_params); +		icon_id = session_id;  		mSessions[session_id] = floaterp;  		floaterp->mCloseSignal.connect(boost::bind(&LLFloaterIMContainer::onCloseFloater, this, session_id)); @@ -321,11 +324,18 @@ void LLFloaterIMContainer::addFloater(LLFloater* floaterp,  		LLAvatarIconCtrl::Params icon_params;  		icon_params.avatar_id = avatar_id;  		icon = LLUICtrlFactory::instance().create<LLAvatarIconCtrl>(icon_params); +		icon_id = avatar_id;  		mSessions[session_id] = floaterp;  		floaterp->mCloseSignal.connect(boost::bind(&LLFloaterIMContainer::onCloseFloater, this, session_id));  	} +	LLFloaterIMSessionTab* floater = LLFloaterIMSessionTab::getConversation(session_id); +	if (floater) +	{ +		floater->updateChatIcon(icon_id); +	} +  	// forced resize of the floater  	LLRect wrapper_rect = this->mTabContainer->getLocalRect();  	floaterp->setRect(wrapper_rect); diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 3aee08482b..c75109db36 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -32,6 +32,8 @@  #include "llagent.h"  #include "llagentcamera.h"  #include "llavataractions.h" +#include "llavatariconctrl.h" +#include "llgroupiconctrl.h"  #include "llchatentry.h"  #include "llchathistory.h"  #include "llchiclet.h" @@ -45,6 +47,9 @@  #include "llfloaterimnearbychat.h"  const F32 REFRESH_INTERVAL = 1.0f; +const std::string ICN_GROUP("group_chat_icon"); +const std::string ICN_NEARBY("nearby_chat_icon"); +const std::string ICN_AVATAR("avatar_icon");  void cb_group_do_nothing()  { @@ -693,6 +698,39 @@ void LLFloaterIMSessionTab::updateSessionName(const std::string& name)  	mInputEditor->setLabel(LLTrans::getString("IM_to_label") + " " + name);  } +void LLFloaterIMSessionTab::updateChatIcon(const LLUUID& id) +{ +	if (mSession) +	{ +		if (mSession->isP2PSessionType()) +		{ +			LLAvatarIconCtrl* icon = getChild<LLAvatarIconCtrl>(ICN_AVATAR); +			icon->setVisible(true); +			icon->setValue(id); +		} +		if (mSession->isAdHocSessionType()) +		{ +			LLGroupIconCtrl* icon = getChild<LLGroupIconCtrl>(ICN_GROUP); +			icon->setVisible(true); +		} +		if (mSession->isGroupSessionType()) +		{ +			LLGroupIconCtrl* icon = getChild<LLGroupIconCtrl>(ICN_GROUP); +			icon->setVisible(true); +			icon->setValue(id); +		} +	} +	else +	{ +		if (mIsNearbyChat) +		{ +			LLIconCtrl* icon = getChild<LLIconCtrl>(ICN_NEARBY); +			icon->setVisible(true); +		} +	} + +} +  void LLFloaterIMSessionTab::hideAllStandardButtons()  {  	for (S32 i = 0; i < BUTTON_COUNT; i++) diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h index 1b4922fd73..169eb1cf7f 100644 --- a/indra/newview/llfloaterimsessiontab.h +++ b/indra/newview/llfloaterimsessiontab.h @@ -103,6 +103,8 @@ public:  	void restoreFloater();  	void saveCollapsedState(); +	void updateChatIcon(const LLUUID& id); +  	LLView* getChatHistory();  protected: diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index d2bd716f55..12d82d101f 100644 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -39,6 +39,7 @@  #include "llfloaterimcontainer.h"  #include "llimview.h" // for gIMMgr  #include "llnotificationsutil.h" +#include "llstartup.h"  #include "llstatusbar.h"	// can_afford_transaction()  #include "groupchatlistener.h" @@ -55,6 +56,11 @@ public:  	bool handle(const LLSD& tokens, const LLSD& query_map,  				LLMediaCtrl* web)  	{ +		if (LLStartUp::getStartupState() < STATE_STARTED) +		{ +			return true; +		} +  		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableGroupInfo"))  		{  			LLNotificationsUtil::add("NoGroupInfo", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index c02c9c95a0..801fb8b9b2 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -29,7 +29,7 @@  #include "llpanel.h"  #include "llsettingssky.h" -#include "llfloaterfixedenvironment.h" +#include "llfloatereditenvironmentbase.h"  //=========================================================================  class LLSlider; diff --git a/indra/newview/llpaneleditwater.h b/indra/newview/llpaneleditwater.h index ab2dc47bcc..4b7ec903c9 100644 --- a/indra/newview/llpaneleditwater.h +++ b/indra/newview/llpaneleditwater.h @@ -30,7 +30,7 @@  #include "llpanel.h"  #include "llsettingswater.h" -#include "llfloaterfixedenvironment.h" +#include "llfloatereditenvironmentbase.h"  //=========================================================================  class LLSlider; diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp index c39df3fe8b..4762e15d8f 100644 --- a/indra/newview/llpanelpicks.cpp +++ b/indra/newview/llpanelpicks.cpp @@ -37,6 +37,7 @@  #include "llfloatersidepanelcontainer.h"  #include "llfloaterworldmap.h"  #include "llnotificationsutil.h" +#include "llstartup.h"  #include "lltexturectrl.h"  #include "lltoggleablemenu.h"  #include "lltrans.h" @@ -84,6 +85,11 @@ public:  	bool handle(const LLSD& params, const LLSD& query_map,  		LLMediaCtrl* web)  	{ +		if (LLStartUp::getStartupState() < STATE_STARTED) +		{ +			return true; +		} +  		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnablePicks"))  		{  			LLNotificationsUtil::add("NoPicks", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); @@ -198,6 +204,11 @@ public:  	bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web)  	{ +		if (LLStartUp::getStartupState() < STATE_STARTED) +		{ +			return true; +		} +  		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableClassifieds"))  		{  			LLNotificationsUtil::add("NoClassifieds", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); diff --git a/indra/newview/skins/default/textures/icons/nearby_chat_icon.png b/indra/newview/skins/default/textures/icons/nearby_chat_icon.pngBinary files differ index 5ac4258b9d..2cb577776d 100644 --- a/indra/newview/skins/default/textures/icons/nearby_chat_icon.png +++ b/indra/newview/skins/default/textures/icons/nearby_chat_icon.png diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml index c64ee5565a..15f02ab9c3 100644 --- a/indra/newview/skins/default/xui/en/floater_im_session.xml +++ b/indra/newview/skins/default/xui/en/floater_im_session.xml @@ -267,6 +267,36 @@                   right="-1">                      <layout_panel                       name="input_editor_layout_panel"> +                        <avatar_icon +                         follows="left|bottom" +                         name="avatar_icon" +                         height="20" +                         default_icon_name="Generic_Person" +                         layout="topleft" +                         left="3" +                         bottom="-9" +                         visible="false" +                         width="20" /> +                        <group_icon +                         follows="left|bottom" +                         name="group_chat_icon" +                         height="20" +                         default_icon_name="Generic_Group" +                         layout="topleft" +                         left="3" +                         bottom="-9" +                         visible="false" +                         width="20" /> +                        <icon +                         follows="left|bottom" +                         height="20" +                         image_name="Nearby_chat_icon" +                         layout="topleft" +                         left="3" +                         bottom="-9" +                         name="nearby_chat_icon" +                         visible="false" +                         width="20"/>                          <chat_editor                           layout="topleft"                           expand_lines_count="5" @@ -280,7 +310,7 @@                           spellcheck="true"                           tab_group="3"                           bottom="-8" -                         left="5" +                         left_pad="5"                           right="-5"                           wrap="true" />                      </layout_panel> | 
