diff options
author | Graham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com> | 2018-03-06 23:17:02 +0000 |
---|---|---|
committer | Graham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com> | 2018-03-06 23:17:02 +0000 |
commit | 15ce532ccf0d1fb387b1b048a2ed7153fad83dc2 (patch) | |
tree | 4a78afd7409559501a709c30447745215051155c /indra/llinventory | |
parent | 1687719a2523e1a6a9d8ebc8aeac52c530fa8fd0 (diff) | |
parent | cbe4cac78cf48cb9144dc2f6c194585cff87a1ce (diff) |
Merge
Diffstat (limited to 'indra/llinventory')
-rw-r--r-- | indra/llinventory/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llinventory/llinventorydefines.h | 11 | ||||
-rw-r--r-- | indra/llinventory/llinventorysettings.cpp | 110 | ||||
-rw-r--r-- | indra/llinventory/llinventorysettings.h | 24 | ||||
-rw-r--r-- | indra/llinventory/llinventorytype.cpp | 1 | ||||
-rw-r--r-- | indra/llinventory/llinventorytype.h | 2 | ||||
-rw-r--r-- | indra/llinventory/llinvtranslationbrdg.h | 41 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 18 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 2 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.h | 2 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 5 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.h | 2 |
12 files changed, 192 insertions, 28 deletions
diff --git a/indra/llinventory/CMakeLists.txt b/indra/llinventory/CMakeLists.txt index 2d40dd6443..f1bc28427d 100644 --- a/indra/llinventory/CMakeLists.txt +++ b/indra/llinventory/CMakeLists.txt @@ -23,6 +23,7 @@ set(llinventory_SOURCE_FILES llfoldertype.cpp llinventory.cpp llinventorydefines.cpp + llinventorysettings.cpp llinventorytype.cpp lllandmark.cpp llnotecard.cpp @@ -47,6 +48,7 @@ set(llinventory_HEADER_FILES llinventorydefines.h llinventorysettings.h llinventorytype.h + llinvtranslationbrdg.h lllandmark.h llnotecard.h llparcel.h diff --git a/indra/llinventory/llinventorydefines.h b/indra/llinventory/llinventorydefines.h index b420e98ecb..54562673f3 100644 --- a/indra/llinventory/llinventorydefines.h +++ b/indra/llinventory/llinventorydefines.h @@ -81,13 +81,10 @@ public: II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS = 0x200000, // Whether a returned object is composed of multiple items. - II_FLAGS_WEARABLES_MASK = 0xff, - // Wearables use the low order byte of flags to store the - // LLWearableType::EType enumeration found in newview/llwearable.h - // - II_FLAGS_SETTINGS_MASK = 0x0000ff, - // Settings (like wearables) use the low order byte of flags to store - // the settings type + II_FLAGS_SUBTYPE_MASK = 0x0000ff, + // Some items like Wearables and settings use the low order byte + // of flags to store the sub type of the inventory item. + // see LLWearableType::EType enumeration found in newview/llwearable.h II_FLAGS_PERM_OVERWRITE_MASK = (II_FLAGS_OBJECT_SLAM_PERM | II_FLAGS_OBJECT_SLAM_SALE | 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<LLSettingsDictionary>, + public LLDictionary<LLSettingsType::type_e, SettingsEntry> +{ + 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(); +} diff --git a/indra/llinventory/llinventorysettings.h b/indra/llinventory/llinventorysettings.h index 0d15542fec..fb08190ea9 100644 --- a/indra/llinventory/llinventorysettings.h +++ b/indra/llinventory/llinventorysettings.h @@ -28,15 +28,27 @@ #ifndef LL_INVENTORY_SETTINGS_H #define LL_INVENTORY_SETTINGS_H +#include "llinventorytype.h" +#include "llinvtranslationbrdg.h" -enum class LLSettingsType +class LLSettingsType { - ST_SKY = 0, - ST_WATER = 1, - ST_DAYCYCLE = 2, +public: + enum type_e + { + ST_SKY = 0, + ST_WATER = 1, + ST_DAYCYCLE = 2, - ST_INVALID = 255, - ST_NONE = -1 + ST_INVALID = 255, + ST_NONE = -1 + }; + + static type_e fromInventoryFlags(U32 flags); + static LLInventoryType::EIconName getIconName(type_e type); + + static void initClass(LLTranslationBridge::ptr_t &trans); + static void cleanupClass(); }; diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp index 20c0a12d9e..2b6b53556d 100644 --- a/indra/llinventory/llinventorytype.cpp +++ b/indra/llinventory/llinventorytype.cpp @@ -203,7 +203,6 @@ bool LLInventoryType::cannotRestrictPermissions(LLInventoryType::EType type) { case IT_CALLINGCARD: case IT_LANDMARK: - case IT_SETTINGS: return true; default: return false; diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h index a45bcc364e..86486373b5 100644 --- a/indra/llinventory/llinventorytype.h +++ b/indra/llinventory/llinventorytype.h @@ -111,8 +111,10 @@ public: ICONNAME_LINKFOLDER, ICONNAME_MESH, + ICONNAME_SETTINGS, ICONNAME_SETTINGS_SKY, ICONNAME_SETTINGS_WATER, + ICONNAME_SETTINGS_DAY, ICONNAME_INVALID, ICONNAME_COUNT, diff --git a/indra/llinventory/llinvtranslationbrdg.h b/indra/llinventory/llinvtranslationbrdg.h new file mode 100644 index 0000000000..fbd887030a --- /dev/null +++ b/indra/llinventory/llinvtranslationbrdg.h @@ -0,0 +1,41 @@ +/** +* @file llinvtranslationbrdg.h +* @brief Translation adapter for inventory. +* +* $LicenseInfo:firstyear=2002&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2010, 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$ +*/ + +#ifndef LL_TRANSLATIONBRDG_H +#define LL_TRANSLATIONBRDG_H + +class LLTranslationBridge +{ +public: + typedef std::shared_ptr<LLTranslationBridge> ptr_t; + + // clang needs this to be happy + virtual ~LLTranslationBridge() {} + + virtual std::string getString(const std::string &xml_desc) = 0; +}; + +#endif diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index c34d365a0b..62a88cde73 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -68,7 +68,7 @@ public: //--------------------------------------------------------------------- virtual std::string getSettingType() const = 0; - virtual LLSettingsType getSettingTypeValue() const = 0; + virtual LLSettingsType::type_e getSettingTypeValue() const = 0; //--------------------------------------------------------------------- // Settings status @@ -149,16 +149,16 @@ public: // Note this method is marked const but may modify the settings object. // (note the internal const cast). This is so that it may be called without // special consideration from getters. - inline void update() const + inline void update() const { if (!mDirty) return; (const_cast<LLSettingsBase *>(this))->updateSettings(); } - virtual void blend(const ptr_t &end, F64 blendf) = 0; + virtual void blend(const ptr_t &end, F64 blendf) = 0; - virtual bool validate(); + virtual bool validate(); class Validator { @@ -231,16 +231,16 @@ protected: virtual parammapping_t getParameterMap() const { return parammapping_t(); } - LLSD mSettings; - bool mIsValid; + LLSD mSettings; + bool mIsValid; LLAssetID mAssetID; - LLSD cloneSettings() const; + LLSD cloneSettings() const; private: - bool mDirty; + bool mDirty; - LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; + LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; }; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 0e0554d9d5..70826d1410 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -127,6 +127,8 @@ LLSD LLSettingsDay::getSettings() const if (mSettings.has(SETTING_ID)) settings[SETTING_ID] = mSettings[SETTING_ID]; + settings[SETTING_TYPE] = getSettingType(); + std::map<std::string, LLSettingsBase::ptr_t> in_use; LLSD tracks(LLSD::emptyArray()); diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 2d0fa4a840..da572572c4 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -72,7 +72,7 @@ public: virtual ptr_t buildClone() = 0; virtual LLSD getSettings() const override; - virtual LLSettingsType getSettingTypeValue() const override { return LLSettingsType::ST_DAYCYCLE; } + virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_DAYCYCLE; } //--------------------------------------------------------------------- diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 4884f4f094..d08e2bbd03 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -90,7 +90,7 @@ public: //--------------------------------------------------------------------- virtual std::string getSettingType() const override { return std::string("sky"); } - virtual LLSettingsType getSettingTypeValue() const override { return LLSettingsType::ST_SKY; } + virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_SKY; } // Settings status @@ -104,7 +104,6 @@ public: } //--------------------------------------------------------------------- -// LEGACY_ATMOSPHERICS LLColor3 getAmbientColor() const { return LLColor3(mSettings[SETTING_AMBIENT]); @@ -433,7 +432,7 @@ public: virtual validation_list_t getValidationList() const override; static validation_list_t validationList(); - static LLSD translateLegacySettings(LLSD legacy); + static LLSD translateLegacySettings(LLSD legacy); protected: static const std::string SETTING_LEGACY_EAST_ANGLE; diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index d4152acfa1..92190fa7b1 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -58,7 +58,7 @@ public: //--------------------------------------------------------------------- virtual std::string getSettingType() const override { return std::string("water"); } - virtual LLSettingsType getSettingTypeValue() const override { return LLSettingsType::ST_WATER; } + virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_WATER; } // Settings status virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override; |