MAINT-8821: Tighten up floater. Allow apply from gear menu.

meow-7.2.2
Rider Linden 2018-07-10 15:15:47 -07:00
parent e7ed4b4584
commit 294793b9a9
10 changed files with 150 additions and 29 deletions

View File

@ -366,9 +366,9 @@ bool LLEnvironment::canAgentUpdateParcelEnvironment(bool useselected) const
{
if (!LLEnvironment::instance().isExtendedEnvironmentEnabled())
return false;
// *TODO*
//LLParcel* parcel = (useselected) ? LLViewerParcelMgr::instance().getParcelSelection() : LLViewerParcelMgr::instance().getAgentParcel();
LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel();
LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel());
if (parcel)
{
return parcel->allowTerraformBy(gAgent.getID());

View File

@ -149,14 +149,14 @@ public:
bool canEdit() const;
bool isExtendedEnvironmentEnabled() const;
bool isInventoryEnabled() const;
bool canAgentUpdateParcelEnvironment(bool useselected = false) const;
bool canAgentUpdateParcelEnvironment(bool useselected = true) const;
bool canAgentUpdateRegionEnvironment() const;
LLSettingsDay::ptr_t getCurrentDay() const { return mCurrentEnvironment->getDayCycle(); }
LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); }
LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); }
static void getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky);
static void getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky);
void update(const LLViewerCamera * cam);

View File

@ -48,6 +48,8 @@
#include "llviewercontrol.h"
#include "llfloaterperms.h"
#include "llenvironment.h"
#include "llparcel.h"
#include "llviewerparcelmgr.h"
//=========================================================================
namespace
@ -61,6 +63,23 @@ namespace
const std::string BUTTON_GEAR("btn_newsettings");
const std::string BUTTON_DELETE("btn_del");
const std::string ACTION_DOCREATE("MyEnvironments.DoCreate");
const std::string ACTION_DOEDIT("MyEnvironments.DoEdit");
const std::string ACTION_DOAPPLY("MyEnvironments.DoApply");
const std::string ACTION_COPYPASTE("MyEnvironments.CopyPaste");
const std::string ENABLE_ACTION("MyEnvironments.EnableAction");
const std::string ENABLE_CANAPPLY("MyEnvironments.CanApply");
const std::string ENABLE_ENVIRONMENT("MyEnvironments.EnvironmentEnabled");
const std::string PARAMETER_REGION("region");
const std::string PARAMETER_PARCEL("parcel");
const std::string PARAMETER_LOCAL("local");
const std::string PARAMETER_EDIT("edit");
const std::string PARAMETER_COPY("copy");
const std::string PARAMETER_PASTE("paste");
const std::string PARAMETER_COPYUUID("copy_uuid");
}
//=========================================================================
@ -137,21 +156,15 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) :
mTypeFilter((0x01 << static_cast<U64>(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast<U64>(LLSettingsType::ST_SKY)) | (0x01 << static_cast<U64>(LLSettingsType::ST_WATER))),
mSelectedAsset()
{
mCommitCallbackRegistrar.add("MyEnvironments.DoCreate", [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); });
mCommitCallbackRegistrar.add(ACTION_DOCREATE, [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); });
mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) {});
mCommitCallbackRegistrar.add(ACTION_DOAPPLY, [this](LLUICtrl *, const LLSD &userdata) { onDoApply(userdata.asString()); });
mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) {});
mEnableCallbackRegistrar.add("MyEnvironments.EnvironmentEnabled", [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); });
mEnableCallbackRegistrar.add(ENABLE_ACTION, [this](LLUICtrl *, const LLSD &userdata) { return canAction(userdata.asString()); });
mEnableCallbackRegistrar.add(ENABLE_CANAPPLY, [this](LLUICtrl *, const LLSD &userdata) { return canApply(userdata.asString()); });
mEnableCallbackRegistrar.add(ENABLE_ENVIRONMENT, [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); });
#if 0
mObserver = new LLFloaterGestureObserver(this);
LLGestureMgr::instance().addObserver(mObserver);
mCommitCallbackRegistrar.add("Gesture.Action.ToogleActiveState", boost::bind(&LLFloaterGesture::onActivateBtnClick, this));
mCommitCallbackRegistrar.add("Gesture.Action.ShowPreview", boost::bind(&LLFloaterGesture::onClickEdit, this));
mCommitCallbackRegistrar.add("Gesture.Action.CopyPaste", boost::bind(&LLFloaterGesture::onCopyPasteAction, this, _2));
mCommitCallbackRegistrar.add("Gesture.Action.SaveToCOF", boost::bind(&LLFloaterGesture::addToCurrentOutFit, this));
mEnableCallbackRegistrar.add("Gesture.EnableAction", boost::bind(&LLFloaterGesture::isActionEnabled, this, _2));
#endif
}
LLFloaterMyEnvironment::~LLFloaterMyEnvironment()
@ -279,8 +292,6 @@ void LLFloaterMyEnvironment::onDeleteSelected()
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(inv_item);
new_item->setParent(trash_id);
// no need to restamp it though it's a move into trash because
// it's a brand new item already.
new_item->updateParentOnServer(FALSE);
gInventory.updateItem(new_item);
}
@ -294,6 +305,91 @@ void LLFloaterMyEnvironment::onDoCreate(const LLSD &data)
menu_create_inventory_item(mInventoryList, NULL, data);
}
void LLFloaterMyEnvironment::onDoApply(const std::string &context)
{
uuid_vec_t selected;
getSelectedIds(selected);
if (selected.size() != 1) // Exactly one item selected.
return;
LLUUID item_id(selected.front());
LLInventoryItem* itemp = gInventory.getItem(item_id);
if (itemp && itemp->getInventoryType() == LLInventoryType::IT_SETTINGS)
{
LLUUID asset_id = itemp->getAssetUUID();
if (context == PARAMETER_REGION)
{
LLEnvironment::instance().updateRegion(asset_id, -1, -1);
}
else if (context == PARAMETER_PARCEL)
{
LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel());
if (!parcel)
{
LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL;
return;
}
LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, -1, -1);
}
else if (context == PARAMETER_LOCAL)
{
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, asset_id);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
}
bool LLFloaterMyEnvironment::canAction(const std::string &context)
{
// uuid_vec_t selected;
// getSelectedIds(selected);
//
// if (selected.empty())
// return false;
//
// if (context == PARAMETER_EDIT)
// {
// }
// else if (context == PARAMETER_COPY)
// {
// }
// else if (context == PARAMETER_PASTE)
// {
// }
// else if (context == PARAMETER_COPYUUID)
// {
// }
return false;
}
bool LLFloaterMyEnvironment::canApply(const std::string &context)
{
uuid_vec_t selected;
getSelectedIds(selected);
if (selected.size() != 1) // Exactly one item selected.
return false;
if (context == PARAMETER_REGION)
{
return LLEnvironment::instance().canAgentUpdateRegionEnvironment();
}
else if (context == PARAMETER_PARCEL)
{
return LLEnvironment::instance().canAgentUpdateParcelEnvironment();
}
else
{
return (context == PARAMETER_LOCAL);
}
}
//-------------------------------------------------------------------------
void LLFloaterMyEnvironment::refreshButtonStates()
{

View File

@ -69,6 +69,9 @@ private:
void onSelectionChange();
void onDeleteSelected();
void onDoCreate(const LLSD &data);
void onDoApply(const std::string &context);
bool canAction(const std::string &context);
bool canApply(const std::string &context);
void getSelectedIds(uuid_vec_t& ids) const;
void refreshButtonStates();

View File

@ -6926,7 +6926,7 @@ void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action
return;
LLUUID asset_id = item->getAssetUUID();
LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
LLParcel *parcel = LLViewerParcelMgr::instance().getAgentOrSelectedParcel();
if (!parcel)
{
LL_WARNS("INVENTORY") << "could not identify parcel." << LL_ENDL;

View File

@ -62,7 +62,7 @@ public:
LLPanelSettingsSkyAtmosTab();
virtual BOOL postBuild() override;
virtual void setEnabled(BOOL enabled);
virtual void setEnabled(BOOL enabled) override;
protected:
virtual void refresh() override;
@ -87,7 +87,7 @@ public:
LLPanelSettingsSkyCloudTab();
virtual BOOL postBuild() override;
virtual void setEnabled(BOOL enabled);
void setEnabled(BOOL enabled) override;
protected:
virtual void refresh() override;
@ -110,7 +110,7 @@ public:
LLPanelSettingsSkySunMoonTab();
virtual BOOL postBuild() override;
virtual void setEnabled(BOOL enabled);
virtual void setEnabled(BOOL enabled) override;
protected:
virtual void refresh() override;

View File

@ -66,7 +66,7 @@ public:
LLPanelSettingsWaterMainTab();
virtual BOOL postBuild() override;
virtual void setEnabled(BOOL enabled);
virtual void setEnabled(BOOL enabled) override;
protected:
virtual void refresh() override;

View File

@ -647,6 +647,27 @@ LLParcel *LLViewerParcelMgr::getAgentParcel() const
return mAgentParcel;
}
LLParcel * LLViewerParcelMgr::getAgentOrSelectedParcel() const
{
LLParcel *parcel(nullptr);
LLParcelSelectionHandle sel_handle(getFloatingParcelSelection());
if (sel_handle)
{
LLParcelSelection *selection(sel_handle.get());
if (selection)
{
parcel = selection->getParcel();
}
}
if (!parcel)
parcel = LLViewerParcelMgr::instance().getAgentParcel();
return parcel;
}
// Return whether the agent can build on the land they are on
bool LLViewerParcelMgr::allowAgentBuild() const
{

View File

@ -154,6 +154,7 @@ public:
//LLParcel *getParcelSelection() const;
LLParcel *getAgentParcel() const;
LLParcel *getAgentOrSelectedParcel() const;
BOOL inAgentParcel(const LLVector3d &pos_global) const;

View File

@ -9,7 +9,7 @@
layout="topleft"
name="edit_settings">
<on_click
function="MyEnvironments.ShowPreview" />
function="MyEnvironments.DoEdit" />
<on_enable
function="MyEnvironments.EnableAction"
parameter="edit_settings" />
@ -33,7 +33,7 @@
function="MyEnvironments.DoApply"
parameter="parcel" />
<menu_item_call.on_enable
function="MyEnvironments.CanAppyl"
function="MyEnvironments.CanApply"
parameter="parcel"/>
</menu_item_call>
<menu_item_call
@ -41,10 +41,10 @@
layout="topleft"
label="Apply To Region">
<menu_item_call.on_click
function="MyEnvironments.DoToSelected"
function="MyEnvironments.DoApply"
parameter="region" />
<menu_item_call.on_enable
function="MyEnvironments.CanAppyl"
function="MyEnvironments.CanApply"
parameter="region"/>
</menu_item_call>
<menu_item_separator