SL-13516 Move dupplicated functionality of evironment editors into separate class

master
Andrey Kleshchev 2020-07-17 23:19:37 +03:00
parent 4d27b11a16
commit 9d2c405ee4
9 changed files with 683 additions and 827 deletions

View File

@ -235,6 +235,7 @@ set(viewer_SOURCE_FILES
llfloaterconversationpreview.cpp
llfloaterdeleteprefpreset.cpp
llfloaterdestinations.cpp
llfloatereditenvironmentbase.cpp
llfloatereditextdaycycle.cpp
llfloaterenvironmentadjust.cpp
llfloaterevent.cpp
@ -865,6 +866,7 @@ set(viewer_HEADER_FILES
llfloaterconversationpreview.h
llfloaterdeleteprefpreset.h
llfloaterdestinations.h
llfloatereditenvironmentbase.h
llfloatereditextdaycycle.h
llfloaterenvironmentadjust.h
llfloaterevent.h

View File

@ -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&notif, 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();
}
//=========================================================================

View File

@ -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

View File

@ -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&notif, 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;

View File

@ -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();
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;

View File

@ -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&notif, 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)

View File

@ -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,26 +54,17 @@ 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;
@ -86,24 +72,9 @@ protected:
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);
@ -113,10 +84,8 @@ protected:
virtual void clearDirtyFlag();
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 +95,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 +138,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

View File

@ -29,7 +29,7 @@
#include "llpanel.h"
#include "llsettingssky.h"
#include "llfloaterfixedenvironment.h"
#include "llfloatereditenvironmentbase.h"
//=========================================================================
class LLSlider;

View File

@ -30,7 +30,7 @@
#include "llpanel.h"
#include "llsettingswater.h"
#include "llfloaterfixedenvironment.h"
#include "llfloatereditenvironmentbase.h"
//=========================================================================
class LLSlider;