summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/CMakeLists.txt1
-rw-r--r--indra/llinventory/llinventorysettings.h43
-rw-r--r--indra/llinventory/llsettingsbase.cpp23
-rw-r--r--indra/llinventory/llsettingsbase.h29
-rw-r--r--indra/llinventory/llsettingsdaycycle.cpp1
-rw-r--r--indra/llinventory/llsettingsdaycycle.h2
-rw-r--r--indra/llinventory/llsettingssky.h4
-rw-r--r--indra/llinventory/llsettingswater.h3
8 files changed, 90 insertions, 16 deletions
diff --git a/indra/llinventory/CMakeLists.txt b/indra/llinventory/CMakeLists.txt
index 3eba746614..2d40dd6443 100644
--- a/indra/llinventory/CMakeLists.txt
+++ b/indra/llinventory/CMakeLists.txt
@@ -45,6 +45,7 @@ set(llinventory_HEADER_FILES
llfoldertype.h
llinventory.h
llinventorydefines.h
+ llinventorysettings.h
llinventorytype.h
lllandmark.h
llnotecard.h
diff --git a/indra/llinventory/llinventorysettings.h b/indra/llinventory/llinventorysettings.h
new file mode 100644
index 0000000000..0d15542fec
--- /dev/null
+++ b/indra/llinventory/llinventorysettings.h
@@ -0,0 +1,43 @@
+/**
+* @file llinventorysettings.h
+* @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$
+*/
+
+#ifndef LL_INVENTORY_SETTINGS_H
+#define LL_INVENTORY_SETTINGS_H
+
+
+enum class LLSettingsType
+{
+ ST_SKY = 0,
+ ST_WATER = 1,
+ ST_DAYCYCLE = 2,
+
+ ST_INVALID = 255,
+ ST_NONE = -1
+};
+
+
+#endif
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index 7ade345168..3382716577 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -39,6 +39,14 @@ namespace
}
//=========================================================================
+std::ostream &::operator <<(std::ostream& os, LLSettingsBase &settings)
+{
+ LLSDSerialize::serialize(settings.getSettings(), os, LLSDSerialize::LLSD_NOTATION);
+
+ return os;
+}
+
+//=========================================================================
const std::string LLSettingsBase::SETTING_ID("id");
const std::string LLSettingsBase::SETTING_NAME("name");
const std::string LLSettingsBase::SETTING_HASH("hash");
@@ -49,13 +57,15 @@ const F64Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01);
//=========================================================================
LLSettingsBase::LLSettingsBase():
mSettings(LLSD::emptyMap()),
- mDirty(true)
+ mDirty(true),
+ mAssetID()
{
}
LLSettingsBase::LLSettingsBase(const LLSD setting) :
mSettings(setting),
- mDirty(true)
+ mDirty(true),
+ mAssetID()
{
}
@@ -368,8 +378,14 @@ bool LLSettingsBase::Validator::verify(LLSD &data)
{
if (!data.has(mName) || (data.has(mName) && data[mName].isUndefined()))
{
+ if (!mDefault.isUndefined())
+ {
+ LL_INFOS("SETTINGS") << "Inserting missing default for '" << mName << "'." << LL_ENDL;
+ data[mName] = mDefault;
+ return true;
+ }
if (mRequired)
- LL_WARNS("SETTINGS") << "Missing required setting '" << mName << "'" << LL_ENDL;
+ LL_WARNS("SETTINGS") << "Missing required setting '" << mName << "' with no default." << LL_ENDL;
return !mRequired;
}
@@ -514,7 +530,6 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range)
}
//=========================================================================
-
void LLSettingsBlender::update(F64Seconds timedelta)
{
mTimeSpent += timedelta;
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 420bcb9943..c7ed9e9e21 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -42,6 +42,8 @@
#include "v4color.h"
#include "v3color.h"
+#include "llinventorysettings.h"
+
class LLSettingsBase :
public std::enable_shared_from_this<LLSettingsBase>,
private boost::noncopyable
@@ -49,6 +51,8 @@ class LLSettingsBase :
friend class LLEnvironment;
friend class LLSettingsDay;
+ friend std::ostream &operator <<(std::ostream& os, LLSettingsBase &settings);
+
public:
static const std::string SETTING_ID;
static const std::string SETTING_NAME;
@@ -64,6 +68,8 @@ public:
//---------------------------------------------------------------------
virtual std::string getSettingType() const = 0;
+ virtual LLSettingsType getSettingTypeValue() const = 0;
+
//---------------------------------------------------------------------
// Settings status
inline bool hasSetting(const std::string &param) const { return mSettings.has(param); }
@@ -143,27 +149,28 @@ 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
{
public:
typedef boost::function<bool(LLSD &)> verify_pr;
- Validator(std::string name, bool required, LLSD::Type type, verify_pr verify = verify_pr()) :
+ Validator(std::string name, bool required, LLSD::Type type, verify_pr verify = verify_pr(), LLSD defval = LLSD()) :
mName(name),
mRequired(required),
mType(type),
- mVerify(verify)
+ mVerify(verify),
+ mDefault(defval)
{ }
std::string getName() const { return mName; }
@@ -187,6 +194,7 @@ public:
bool mRequired;
LLSD::Type mType;
verify_pr mVerify;
+ LLSD mDefault;
};
typedef std::vector<Validator> validation_list_t;
@@ -223,15 +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 a689dd3710..18add703cb 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -273,6 +273,7 @@ LLSD LLSettingsDay::defaults()
(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")));
dfltsetting[SETTING_FRAMES] = LLSD::emptyMap();
+ dfltsetting[SETTING_TYPE] = "daycycle";
return dfltsetting;
}
diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h
index 4c7ce011a1..7703f7a0b4 100644
--- a/indra/llinventory/llsettingsdaycycle.h
+++ b/indra/llinventory/llsettingsdaycycle.h
@@ -72,6 +72,8 @@ public:
virtual ptr_t buildClone() = 0;
virtual LLSD getSettings() const;
+ virtual LLSettingsType getSettingTypeValue() const override { return LLSettingsType::ST_DAYCYCLE; }
+
//---------------------------------------------------------------------
virtual std::string getSettingType() const { return std::string("daycycle"); }
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index e9ffbdb32c..23daf0c5dc 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -72,7 +72,9 @@ public:
virtual ptr_t buildClone() = 0;
//---------------------------------------------------------------------
- virtual std::string getSettingType() const { return std::string("sky"); }
+ virtual std::string getSettingType() const override { return std::string("sky"); }
+ virtual LLSettingsType getSettingTypeValue() const override { return LLSettingsType::ST_SKY; }
+
// Settings status
virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf);
diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h
index 4d206a1be0..16d5b2353a 100644
--- a/indra/llinventory/llsettingswater.h
+++ b/indra/llinventory/llsettingswater.h
@@ -57,7 +57,8 @@ public:
virtual ptr_t buildClone() = 0;
//---------------------------------------------------------------------
- virtual std::string getSettingType() const { return std::string("water"); }
+ virtual std::string getSettingType() const override { return std::string("water"); }
+ virtual LLSettingsType getSettingTypeValue() const override { return LLSettingsType::ST_WATER; }
// Settings status
virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf);