From cbe4cac78cf48cb9144dc2f6c194585cff87a1ce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 6 Mar 2018 14:58:39 -0800 Subject: Settings type inventory objects and upload the assests. --- indra/llinventory/llinventorysettings.cpp | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 indra/llinventory/llinventorysettings.cpp (limited to 'indra/llinventory/llinventorysettings.cpp') diff --git a/indra/llinventory/llinventorysettings.cpp b/indra/llinventory/llinventorysettings.cpp new file mode 100644 index 0000000000..0928e35e95 --- /dev/null +++ b/indra/llinventory/llinventorysettings.cpp @@ -0,0 +1,110 @@ +/** +* @file llinventorysettings.cpp +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, 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 "linden_common.h" +#include "llinventorysettings.h" +#include "llinventorytype.h" +#include "llinventorydefines.h" +#include "lldictionary.h" +#include "llsingleton.h" +#include "llinvtranslationbrdg.h" + +//========================================================================= +namespace { + LLTranslationBridge::ptr_t sTranslator; +} + +//========================================================================= +struct SettingsEntry : public LLDictionaryEntry +{ + SettingsEntry(const std::string &name, + const std::string& default_new_name, + LLInventoryType::EIconName iconName) : + LLDictionaryEntry(name), + mDefaultNewName(default_new_name), + mLabel(name), + mIconName(iconName) + { + std::string transdname = sTranslator->getString(mLabel); + if (!transdname.empty()) + { + mLabel = transdname; + } + } + + std::string mLabel; + std::string mDefaultNewName; //keep mLabel for backward compatibility + LLInventoryType::EIconName mIconName; +}; + +class LLSettingsDictionary : public LLSingleton, + public LLDictionary +{ + LLSINGLETON(LLSettingsDictionary); + + void initSingleton() override; +}; + +LLSettingsDictionary::LLSettingsDictionary() +{ +} + +void LLSettingsDictionary::initSingleton() +{ + addEntry(LLSettingsType::ST_SKY, new SettingsEntry("sky", "New Sky", LLInventoryType::ICONNAME_SETTINGS_SKY)); + addEntry(LLSettingsType::ST_WATER, new SettingsEntry("water", "New Water", LLInventoryType::ICONNAME_SETTINGS_WATER)); + addEntry(LLSettingsType::ST_DAYCYCLE, new SettingsEntry("day", "New Day", LLInventoryType::ICONNAME_SETTINGS_DAY)); + addEntry(LLSettingsType::ST_NONE, new SettingsEntry("none", "New Settings", LLInventoryType::ICONNAME_SETTINGS)); + addEntry(LLSettingsType::ST_INVALID, new SettingsEntry("invalid", "New Settings", LLInventoryType::ICONNAME_SETTINGS)); +} + +//========================================================================= + +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); + if (!entry) + return getIconName(ST_INVALID); + return entry->mIconName; +} + + +void LLSettingsType::initClass(LLTranslationBridge::ptr_t &trans) +{ + sTranslator = trans; +} + +void LLSettingsType::cleanupClass() +{ + sTranslator.reset(); +} -- cgit v1.3 From c11c17ed7b5c614a6c8505088aa709ddd9f1f1a4 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 6 Mar 2018 23:44:09 +0000 Subject: Remove override keyword not working with LL_SINGLETON pattern. --- indra/llinventory/llinventorysettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llinventory/llinventorysettings.cpp') diff --git a/indra/llinventory/llinventorysettings.cpp b/indra/llinventory/llinventorysettings.cpp index 0928e35e95..8887c23a6c 100644 --- a/indra/llinventory/llinventorysettings.cpp +++ b/indra/llinventory/llinventorysettings.cpp @@ -66,7 +66,7 @@ class LLSettingsDictionary : public LLSingleton, { LLSINGLETON(LLSettingsDictionary); - void initSingleton() override; + void initSingleton(); }; LLSettingsDictionary::LLSettingsDictionary() -- cgit v1.3 From d6ede8e81cad497a6cd8482dfb48c99bdf5c258a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 30 Jul 2018 15:54:36 -0700 Subject: MAINT-8904: Creating new setting in inventory now causes simulator to assign default asset ID to inventory item. --- indra/llinventory/llinventorysettings.cpp | 8 ++++++- indra/llinventory/llinventorysettings.h | 1 + indra/newview/llsettingsvo.cpp | 39 +++++++++++++++++++++++++++++++ indra/newview/llsettingsvo.h | 1 + indra/newview/llviewerinventory.cpp | 20 +++++----------- 5 files changed, 54 insertions(+), 15 deletions(-) (limited to 'indra/llinventory/llinventorysettings.cpp') 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 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 asset_download_fn; typedef std::function 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 { -- cgit v1.3