Now that I'm more awake, this is a far better solution for the default sim features issues.
Adds const Type mDefaultValue reset() and getDefault() to SignaledType Cleans up code by not needing to reset to the default by value every time, nice template function to do this~ Leaves in hg boolean, but commented out in case opensim ever decides to make that a reality.
This commit is contained in:
@@ -56,42 +56,52 @@ void LFSimFeatureHandler::handleRegionChange()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void has_feature_or_default(SignaledType<T>& type, const LLSD& features, const std::string& feature)
|
||||||
|
{
|
||||||
|
type = (features.has(feature)) ? static_cast<T>(features[feature]) : type.getDefault();
|
||||||
|
}
|
||||||
|
template<>
|
||||||
|
void has_feature_or_default(SignaledType<U32>& type, const LLSD& features, const std::string& feature)
|
||||||
|
{
|
||||||
|
type = (features.has(feature)) ? features[feature].asInteger() : type.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
void LFSimFeatureHandler::setSupportedFeatures()
|
void LFSimFeatureHandler::setSupportedFeatures()
|
||||||
{
|
{
|
||||||
if (LLViewerRegion* region = gAgent.getRegion())
|
if (LLViewerRegion* region = gAgent.getRegion())
|
||||||
{
|
{
|
||||||
LLSD info;
|
LLSD info;
|
||||||
region->getSimulatorFeatures(info);
|
region->getSimulatorFeatures(info);
|
||||||
bool hg(!gHippoGridManager->getCurrentGrid()->isAvination()); // Singu Note: There should be a flag for this some day.
|
//bool hg(); // Singu Note: There should probably be a flag for this some day.
|
||||||
static bool init(false); // This could be a grid where OpenSimExtras aren't implemented, in that case, don't alter the hg specific members.
|
|
||||||
if (info.has("OpenSimExtras")) // OpenSim specific sim features
|
if (info.has("OpenSimExtras")) // OpenSim specific sim features
|
||||||
{
|
{
|
||||||
// For definition of OpenSimExtras please see
|
// For definition of OpenSimExtras please see
|
||||||
// http://opensimulator.org/wiki/SimulatorFeatures_Extras
|
// http://opensimulator.org/wiki/SimulatorFeatures_Extras
|
||||||
const LLSD& extras(info["OpenSimExtras"]);
|
const LLSD& extras(info["OpenSimExtras"]);
|
||||||
mSupportsExport = extras.has("ExportSupported") ? extras["ExportSupported"].asBoolean() : false;
|
has_feature_or_default(mSupportsExport, extras, "ExportSupported");
|
||||||
if (hg)
|
//if (hg)
|
||||||
{
|
{
|
||||||
mDestinationGuideURL = extras.has("destination-guide-url") ? extras["destination-guide-url"].asString() : "";
|
has_feature_or_default(mDestinationGuideURL, extras, "destination-guide-url");
|
||||||
mMapServerURL = extras.has("map-server-url") ? extras["map-server-url"].asString() : "";
|
mMapServerURL = extras.has("map-server-url") ? extras["map-server-url"].asString() : "";
|
||||||
mSearchURL = extras.has("search-server-url") ? extras["search-server-url"].asString() : "";
|
has_feature_or_default(mSearchURL, extras, "search-server-url");
|
||||||
init = true;
|
|
||||||
}
|
}
|
||||||
mSayRange = extras.has("say-range") ? extras["say-range"].asInteger() : 20;
|
has_feature_or_default(mSayRange, extras, "say-range");
|
||||||
mShoutRange = extras.has("shout-range") ? extras["shout-range"].asInteger() : 100;
|
has_feature_or_default(mShoutRange, extras, "shout-range");
|
||||||
mWhisperRange = extras.has("whisper-range") ? extras["whisper-range"].asInteger() : 10;
|
has_feature_or_default(mWhisperRange, extras, "whisper-range");
|
||||||
}
|
}
|
||||||
else // OpenSim specifics are unsupported reset all to default
|
else // OpenSim specifics are unsupported reset all to default
|
||||||
{
|
{
|
||||||
mSupportsExport = false;
|
mSupportsExport.reset();
|
||||||
if (hg && init)
|
//if (hg)
|
||||||
{
|
{
|
||||||
|
mDestinationGuideURL.reset();
|
||||||
mMapServerURL = "";
|
mMapServerURL = "";
|
||||||
mSearchURL = "";
|
mSearchURL.reset();
|
||||||
}
|
}
|
||||||
mSayRange = 20;
|
mSayRange.reset();
|
||||||
mShoutRange = 100;
|
mShoutRange.reset();
|
||||||
mWhisperRange = 10;
|
mWhisperRange.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ template<typename Type, typename Signal = boost::signals2::signal<void(const Typ
|
|||||||
class SignaledType
|
class SignaledType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SignaledType() : mValue() {}
|
SignaledType() : mValue(), mDefaultValue() {}
|
||||||
SignaledType(Type b) : mValue(b) {}
|
SignaledType(Type b) : mValue(b), mDefaultValue(b) {}
|
||||||
|
|
||||||
typedef typename Signal::slot_type slot_t;
|
typedef typename Signal::slot_type slot_t;
|
||||||
boost::signals2::connection connect(const slot_t& slot) { return mSignal.connect(slot); }
|
boost::signals2::connection connect(const slot_t& slot) { return mSignal.connect(slot); }
|
||||||
@@ -41,10 +41,13 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
operator Type() const { return mValue; }
|
operator Type() const { return mValue; }
|
||||||
|
void reset() { *this = mDefaultValue; }
|
||||||
|
const Type& getDefault() const { return mDefaultValue; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Signal mSignal;
|
Signal mSignal;
|
||||||
Type mValue;
|
Type mValue;
|
||||||
|
const Type mDefaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LFSimFeatureHandler : public LLSingleton<LFSimFeatureHandler>
|
class LFSimFeatureHandler : public LLSingleton<LFSimFeatureHandler>
|
||||||
|
|||||||
Reference in New Issue
Block a user