diff options
author | Rider Linden <rider@lindenlab.com> | 2018-07-10 15:15:47 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-07-10 15:15:47 -0700 |
commit | 294793b9a983a0c26c0e82bd432d4cc311ecb1ba (patch) | |
tree | d0b2b384aef6589f1d375c4746a4b1a5b8547723 /indra | |
parent | e7ed4b4584ca39194bd3202d3d74defd0f0421d0 (diff) |
MAINT-8821: Tighten up floater. Allow apply from gear menu.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llenvironment.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 4 | ||||
-rw-r--r-- | indra/newview/llfloatermyenvironment.cpp | 126 | ||||
-rw-r--r-- | indra/newview/llfloatermyenvironment.h | 3 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.h | 6 | ||||
-rw-r--r-- | indra/newview/llpaneleditwater.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewerparcelmgr.cpp | 21 | ||||
-rw-r--r-- | indra/newview/llviewerparcelmgr.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_settings_gear.xml | 8 |
10 files changed, 150 insertions, 29 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ee5eec59a3..289d0c5388 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -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()); diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index d9a1494424..6f8d4b5203 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -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); diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 4863e4c471..a42a356c49 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -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); }); - - mEnableCallbackRegistrar.add("MyEnvironments.EnvironmentEnabled", [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); }); - -#if 0 - mObserver = new LLFloaterGestureObserver(this); - LLGestureMgr::instance().addObserver(mObserver); + 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) {}); - 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(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(); }); - 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() { diff --git a/indra/newview/llfloatermyenvironment.h b/indra/newview/llfloatermyenvironment.h index 51a44ec1aa..9d9659576d 100644 --- a/indra/newview/llfloatermyenvironment.h +++ b/indra/newview/llfloatermyenvironment.h @@ -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(); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 44a9d0bff4..85e2974c1b 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -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; diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index 30ab22147f..7c49c839ec 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -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; diff --git a/indra/newview/llpaneleditwater.h b/indra/newview/llpaneleditwater.h index 044e8e2b80..5a04f98b05 100644 --- a/indra/newview/llpaneleditwater.h +++ b/indra/newview/llpaneleditwater.h @@ -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; diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index d05d11625f..ed529975d2 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -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 { diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 29219843c9..06dae6e57e 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -154,6 +154,7 @@ public: //LLParcel *getParcelSelection() const; LLParcel *getAgentParcel() const; + LLParcel *getAgentOrSelectedParcel() const; BOOL inAgentParcel(const LLVector3d &pos_global) const; diff --git a/indra/newview/skins/default/xui/en/menu_settings_gear.xml b/indra/newview/skins/default/xui/en/menu_settings_gear.xml index 41fd0fce2c..1d65ff3d99 100644 --- a/indra/newview/skins/default/xui/en/menu_settings_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_settings_gear.xml @@ -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 |