summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llagentwearables.cpp8
-rw-r--r--indra/newview/llagentwearables.h2
-rw-r--r--indra/newview/llpanelmaininventory.cpp16
-rw-r--r--indra/newview/llsettingsvo.cpp9
-rw-r--r--indra/newview/llsettingsvo.h1
-rw-r--r--indra/newview/llviewerinventory.cpp42
-rw-r--r--indra/newview/llviewerinventory.h21
7 files changed, 69 insertions, 30 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 24c6d82b0d..0d63b91882 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1528,7 +1528,7 @@ bool LLAgentWearables::moveWearable(const LLViewerInventoryItem* item, bool clos
}
// static
-void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, const LLUUID& parent_id)
+void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, const LLUUID& parent_id, std::function<void(const LLUUID&)> created_cb)
{
if (type == LLWearableType::WT_INVALID || type == LLWearableType::WT_NONE) return;
@@ -1540,7 +1540,7 @@ void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, con
LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp);
LLAssetType::EType asset_type = wearable->getAssetType();
- LLPointer<LLInventoryCallback> cb;
+ LLPointer<LLBoostFuncInventoryCallback> cb;
if(wear)
{
cb = new LLBoostFuncInventoryCallback(wear_and_edit_cb);
@@ -1549,6 +1549,10 @@ void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, con
{
cb = new LLBoostFuncInventoryCallback(wear_cb);
}
+ if (created_cb != NULL)
+ {
+ cb->addOnFireFunc(created_cb);
+ }
LLUUID folder_id;
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index 2710262910..e20f5df7fa 100644
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -129,7 +129,7 @@ protected:
//--------------------------------------------------------------------
public:
- static void createWearable(LLWearableType::EType type, bool wear = false, const LLUUID& parent_id = LLUUID::null);
+ static void createWearable(LLWearableType::EType type, bool wear = false, const LLUUID& parent_id = LLUUID::null, std::function<void(const LLUUID&)> created_cb = NULL);
static void editWearable(const LLUUID& item_id);
bool moveWearable(const LLViewerInventoryItem* item, bool closer_to_body);
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index a6a68141e3..a28bc33f15 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -516,35 +516,35 @@ void LLPanelMainInventory::doCreate(const LLSD& userdata)
}
LLHandle<LLPanel> handle = getHandle();
- std::function<void(const LLUUID&)> callback_cat_created = [handle](const LLUUID& new_category_id)
+ std::function<void(const LLUUID&)> callback_created = [handle](const LLUUID& new_id)
{
gInventory.notifyObservers(); // not really needed, should have been already done
LLPanelMainInventory* panel = (LLPanelMainInventory*)handle.get();
- if (new_category_id.notNull() && panel)
+ if (new_id.notNull() && panel)
{
// might need to refresh visibility, delay rename
- panel->mCombInvUUIDNeedsRename = new_category_id;
+ panel->mCombInvUUIDNeedsRename = new_id;
}
};
- menu_create_inventory_item(NULL, getCurrentSFVRoot(), userdata, LLUUID::null, callback_cat_created);
+ menu_create_inventory_item(NULL, getCurrentSFVRoot(), userdata, LLUUID::null, callback_created);
}
}
else
{
LLHandle<LLPanel> handle = getHandle();
- std::function<void(const LLUUID&)> callback_cat_created = [handle](const LLUUID &new_category_id)
+ std::function<void(const LLUUID&)> callback_created = [handle](const LLUUID &new_id)
{
gInventory.notifyObservers(); // not really needed, should have been already done
- if (new_category_id.notNull())
+ if (new_id.notNull())
{
LLPanelMainInventory* panel = (LLPanelMainInventory*)handle.get();
if (panel)
{
- panel->setGallerySelection(new_category_id);
+ panel->setGallerySelection(new_id);
}
}
};
- menu_create_inventory_item(NULL, getCurrentSFVRoot(), userdata, LLUUID::null, callback_cat_created);
+ menu_create_inventory_item(NULL, getCurrentSFVRoot(), userdata, LLUUID::null, callback_created);
}
}
else
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index b1eed81476..4cfa6f2f85 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -95,6 +95,15 @@ namespace
//=========================================================================
+void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID& parent_id, std::function<void(const LLUUID&)> created_cb)
+{
+ inventory_result_fn cb = [created_cb](LLUUID asset_id, LLUUID inventory_id, LLUUID object_id, LLSD results)
+ {
+ created_cb(inventory_id);
+ };
+ createNewInventoryItem(stype, parent_id, cb);
+}
+
void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback)
{
LLTransactionID tid;
diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h
index 05ec0e9275..4f410ab7d9 100644
--- a/indra/newview/llsettingsvo.h
+++ b/indra/newview/llsettingsvo.h
@@ -49,6 +49,7 @@ public:
typedef std::function<void(LLInventoryItem *inv_item, LLSettingsBase::ptr_t settings, S32 status, LLExtStat extstat)> inventory_download_fn;
typedef std::function<void(LLUUID asset_id, LLUUID inventory_id, LLUUID object_id, LLSD results)> inventory_result_fn;
+ static void createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID& parent_id, std::function<void(const LLUUID&)> created_cb);
static void createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback = inventory_result_fn());
static void createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback = inventory_result_fn());
static void createInventoryItem(const LLSettingsBase::ptr_t &settings, U32 next_owner_perm, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback = inventory_result_fn());
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 80e4f5f6d5..117cdc5367 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -1644,13 +1644,14 @@ void create_new_item(const std::string& name,
const LLUUID& parent_id,
LLAssetType::EType asset_type,
LLInventoryType::EType inv_type,
- U32 next_owner_perm)
+ U32 next_owner_perm,
+ std::function<void(const LLUUID&)> created_cb = NULL)
{
std::string desc;
LLViewerAssetType::generateDescriptionFor(asset_type, desc);
next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER;
- LLPointer<LLInventoryCallback> cb = NULL;
+ LLPointer<LLBoostFuncInventoryCallback> cb = NULL;
switch (inv_type)
{
@@ -1674,9 +1675,17 @@ void create_new_item(const std::string& name,
next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Notecards");
break;
}
- default:
- break;
- }
+
+ default:
+ {
+ cb = new LLBoostFuncInventoryCallback();
+ break;
+ }
+ }
+ if (created_cb != NULL)
+ {
+ cb->addOnFireFunc(created_cb);
+ }
create_inventory_item(gAgent.getID(),
gAgent.getSessionID(),
@@ -1731,7 +1740,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge,
menu_create_inventory_item(panel, bridge ? bridge->getUUID() : LLUUID::null, userdata, default_parent_uuid);
}
-void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const LLSD& userdata, const LLUUID& default_parent_uuid, std::function<void(const LLUUID&)> folder_created_cb)
+void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const LLSD& userdata, const LLUUID& default_parent_uuid, std::function<void(const LLUUID&)> created_cb)
{
std::string type_name = userdata.asString();
@@ -1754,10 +1763,10 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
}
std::function<void(const LLUUID&)> callback_cat_created = NULL;
- if(panel)
+ if (panel)
{
LLHandle<LLPanel> handle = panel->getHandle();
- std::function<void(const LLUUID&)> callback_cat_created = [handle](const LLUUID &new_category_id)
+ std::function<void(const LLUUID&)> callback_cat_created = [handle](const LLUUID& new_category_id)
{
gInventory.notifyObservers();
LLInventoryPanel* panel = static_cast<LLInventoryPanel*>(handle.get());
@@ -1767,9 +1776,9 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
}
};
}
- else if(folder_created_cb != NULL)
+ else if (created_cb != NULL)
{
- callback_cat_created = folder_created_cb;
+ callback_cat_created = created_cb;
}
gInventory.createNewCategory(
parent_id,
@@ -1784,7 +1793,8 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
parent_id,
LLAssetType::AT_LSL_TEXT,
LLInventoryType::IT_LSL,
- PERM_MOVE | PERM_TRANSFER); // overridden in create_new_item
+ PERM_MOVE | PERM_TRANSFER,
+ created_cb); // overridden in create_new_item
}
else if ("notecard" == type_name)
{
@@ -1793,7 +1803,8 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
parent_id,
LLAssetType::AT_NOTECARD,
LLInventoryType::IT_NOTECARD,
- PERM_ALL); // overridden in create_new_item
+ PERM_ALL,
+ created_cb); // overridden in create_new_item
}
else if ("gesture" == type_name)
{
@@ -1802,7 +1813,8 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
parent_id,
LLAssetType::AT_GESTURE,
LLInventoryType::IT_GESTURE,
- PERM_ALL); // overridden in create_new_item
+ PERM_ALL,
+ created_cb); // overridden in create_new_item
}
else if (("sky" == type_name) || ("water" == type_name) || ("daycycle" == type_name))
{
@@ -1828,7 +1840,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
LLUUID parent_id = dest_id.notNull() ? dest_id : gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS);
- LLSettingsVOBase::createNewInventoryItem(stype, parent_id);
+ LLSettingsVOBase::createNewInventoryItem(stype, parent_id, created_cb);
}
else
{
@@ -1837,7 +1849,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
if (wearable_type >= LLWearableType::WT_SHAPE && wearable_type < LLWearableType::WT_COUNT)
{
const LLUUID parent_id = dest_id;
- LLAgentWearables::createWearable(wearable_type, false, parent_id);
+ LLAgentWearables::createWearable(wearable_type, false, parent_id, created_cb);
}
else
{
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index d788f23d0c..6d3676ba2e 100644
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -256,6 +256,7 @@ protected:
class LLInventoryCallback : public LLRefCount
{
public:
+ virtual ~LLInventoryCallback() {}
virtual void fire(const LLUUID& inv_item) = 0;
};
@@ -294,17 +295,29 @@ class LLBoostFuncInventoryCallback: public LLInventoryCallback
{
public:
- LLBoostFuncInventoryCallback(inventory_func_type fire_func = no_op_inventory_func,
+ LLBoostFuncInventoryCallback(inventory_func_type fire_func,
nullary_func_type destroy_func = no_op):
- mFireFunc(fire_func),
mDestroyFunc(destroy_func)
{
+ mFireFuncs.push_back(fire_func);
}
+ LLBoostFuncInventoryCallback()
+ {
+ }
+
+ void addOnFireFunc(inventory_func_type fire_func)
+ {
+ mFireFuncs.push_back(fire_func);
+ }
+
// virtual
void fire(const LLUUID& item_id)
{
- mFireFunc(item_id);
+ for (inventory_func_type &func: mFireFuncs)
+ {
+ func(item_id);
+ }
}
// virtual
@@ -315,7 +328,7 @@ public:
private:
- inventory_func_type mFireFunc;
+ std::list<inventory_func_type> mFireFuncs;
nullary_func_type mDestroyFunc;
};