diff options
-rw-r--r-- | indra/llinventory/llinventorysettings.cpp | 8 | ||||
-rw-r--r-- | indra/llinventory/llinventorysettings.h | 1 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 39 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.h | 1 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 20 |
5 files changed, 54 insertions, 15 deletions
diff --git a/indra/llinventory/llinventorysettings.cpp b/indra/llinventory/llinventorysettings.cpp index 8887c23a6c..fdad50e8d4 100644 --- a/indra/llinventory/llinventorysettings.cpp +++ b/indra/llinventory/llinventorysettings.cpp @@ -89,7 +89,6 @@ LLSettingsType::type_e LLSettingsType::fromInventoryFlags(U32 flags) return (LLSettingsType::type_e)(flags & LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK); } - LLInventoryType::EIconName LLSettingsType::getIconName(LLSettingsType::type_e type) { const SettingsEntry *entry = LLSettingsDictionary::instance().lookup(type); @@ -98,6 +97,13 @@ LLInventoryType::EIconName LLSettingsType::getIconName(LLSettingsType::type_e ty return entry->mIconName; } +std::string LLSettingsType::getDefaultName(LLSettingsType::type_e type) +{ + const SettingsEntry *entry = LLSettingsDictionary::instance().lookup(type); + if (!entry) + return getDefaultName(ST_INVALID); + return entry->mDefaultNewName; +} void LLSettingsType::initClass(LLTranslationBridge::ptr_t &trans) { diff --git a/indra/llinventory/llinventorysettings.h b/indra/llinventory/llinventorysettings.h index fb08190ea9..906540689c 100644 --- a/indra/llinventory/llinventorysettings.h +++ b/indra/llinventory/llinventorysettings.h @@ -46,6 +46,7 @@ public: static type_e fromInventoryFlags(U32 flags); static LLInventoryType::EIconName getIconName(type_e type); + static std::string getDefaultName(type_e type); static void initClass(LLTranslationBridge::ptr_t &trans); static void cleanupClass(); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index a5187b7363..010b5dec36 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -90,6 +90,31 @@ namespace //========================================================================= +void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback) +{ + LLTransactionID tid; + U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + tid.generate(); + + LLPointer<LLInventoryCallback> cb = new LLSettingsInventoryCB([callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, LLSettingsBase::ptr_t(), callback); + }); + + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, + LLSettingsType::getDefaultName(stype), "new settings collection.", + stype, nextOwnerPerm, cb); +} + + void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, inventory_result_fn callback) { LLTransactionID tid; @@ -116,6 +141,20 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) { + if (!settings) + { // The item was created as new with no settings passed in. Simulator should have given it the default for the type... check ID, + // no need to upload asset. + LLUUID asset_id; + LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); + + if (pitem) + { + asset_id = pitem->getAssetUUID(); + } + if (callback) + callback(asset_id, inventoryId, LLUUID::null, LLSD()); + return; + } // We need to update some inventory stuff here.... maybe. updateInventoryItem(settings, inventoryId, callback); } diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 5d62edd867..15b51d0988 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -47,6 +47,7 @@ public: typedef std::function<void(LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status, LLExtStat extstat)> asset_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, inventory_result_fn callback = inventory_result_fn()); static void createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, inventory_result_fn callback = inventory_result_fn()); static void updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback = inventory_result_fn()); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 09b07b83b8..e4d3d73a3e 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1823,37 +1823,29 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, } else if (("sky" == type_name) || ("water" == type_name) || ("daycycle" == type_name)) { - LLSettingsBase::ptr_t settings; - std::string name; + LLSettingsType::type_e stype(LLSettingsType::ST_NONE); if ("sky" == type_name) { - settings = LLSettingsVOSky::buildDefaultSky(); - name = LLTrans::getString("New Sky"); + stype = LLSettingsType::ST_SKY; } else if ("water" == type_name) { - settings = LLSettingsVOWater::buildDefaultWater(); - name = LLTrans::getString("New Water"); + stype = LLSettingsType::ST_WATER; } else if ("daycycle" == type_name) { - settings = LLSettingsVODay::buildDefaultDayCycle(); - name = LLTrans::getString("New Daycycle"); + stype = LLSettingsType::ST_DAYCYCLE; } else - LL_ERRS(LOG_INV) << "Unknown settings type: '" << type_name << "'" << LL_ENDL; - - if (!settings) { - LL_WARNS(LOG_INV) << "Unable to create a default setting object of type '" << type_name << "'" << LL_ENDL; + LL_ERRS(LOG_INV) << "Unknown settings type: '" << type_name << "'" << LL_ENDL; return; } LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); - settings->setName(name); - LLSettingsVOBase::createInventoryItem(settings, parent_id); + LLSettingsVOBase::createNewInventoryItem(stype, parent_id); } else { |