Rework preset loading and context menu from inventory.

master
Rider Linden 2018-06-01 16:24:36 -07:00
parent bd84cbfa11
commit 2a613d7363
18 changed files with 510 additions and 255 deletions

View File

@ -101,6 +101,9 @@ const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0
const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water
const S32 LLSettingsDay::FRAME_MAX(56);
// *LAPRAS* Change when Agni
const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb");
//=========================================================================
LLSettingsDay::LLSettingsDay(const LLSD &data) :
LLSettingsBase(data),
@ -218,22 +221,18 @@ bool LLSettingsDay::initialize()
if (i == TRACK_WATER)
{
setting = used[(*it)[SETTING_KEYNAME]];
if (!setting)
setting = getNamedWater((*it)[SETTING_KEYNAME]);
if (setting && setting->getSettingType() != "water")
{
LL_WARNS("DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
LL_WARNS("SETTINGS", "DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
setting.reset();
}
}
else
{
setting = used[(*it)[SETTING_KEYNAME]];
if (!setting)
setting = getNamedSky((*it)[SETTING_KEYNAME]);
if (setting && setting->getSettingType() != "sky")
{
LL_WARNS("DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
LL_WARNS("SETTINGS", "DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
setting.reset();
}
}
@ -247,6 +246,10 @@ bool LLSettingsDay::initialize()
hassky |= true;
mDayTracks[i][keyframe] = setting;
}
else
{
LL_WARNS("SETTINGS", "DAYCYCLE") << "Skipping frame on track #" << i << " at time index " << keyframe << LL_ENDL;
}
}
}

View File

@ -60,6 +60,8 @@ public:
static const S32 TRACK_MAX;
static const S32 FRAME_MAX;
static const LLUUID DEFAULT_ASSET_ID;
typedef std::map<F32, LLSettingsBase::ptr_t> CycleTrack_t;
typedef std::vector<CycleTrack_t> CycleList_t;
typedef std::shared_ptr<LLSettingsDay> ptr_t;
@ -105,10 +107,7 @@ public:
virtual LLSettingsSkyPtr_t buildSky(LLSD) const = 0;
virtual LLSettingsWaterPtr_t buildWater(LLSD) const = 0;
virtual LLSettingsSkyPtr_t getNamedSky(const std::string &) const = 0;
virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const = 0;
void setInitialized(bool value = true) { mInitialized = value; }
void setInitialized(bool value = true) { mInitialized = value; }
CycleTrack_t & getCycleTrack(S32 track);
virtual validation_list_t getValidationList() const override;

View File

@ -110,6 +110,9 @@ const LLUUID LLSettingsSky::DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271
const LLUUID LLSettingsSky::DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver
const LLUUID LLSettingsSky::DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b");
// *LAPRAS* Change when Agni!
const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749");
namespace
{
@ -572,8 +575,8 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1;
dfltsetting[SETTING_CLOUD_TEXTUREID] = DEFAULT_CLOUD_ID;
dfltsetting[SETTING_MOON_TEXTUREID] = DEFAULT_MOON_ID; // gMoonTextureID; // These two are returned by the login... wow!
dfltsetting[SETTING_SUN_TEXTUREID] = DEFAULT_SUN_ID; // gSunTextureID;
dfltsetting[SETTING_MOON_TEXTUREID] = DEFAULT_MOON_ID;
dfltsetting[SETTING_SUN_TEXTUREID] = LLUUID::null; // DEFAULT_SUN_ID;
dfltsetting[SETTING_TYPE] = "sky";

View File

@ -83,6 +83,8 @@ public:
static const LLUUID DEFAULT_MOON_ID;
static const LLUUID DEFAULT_CLOUD_ID;
static const LLUUID DEFAULT_ASSET_ID;
typedef std::shared_ptr<LLSettingsSky> ptr_t;
typedef std::pair<F32, F32> azimalt_t;

View File

@ -69,6 +69,9 @@ const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir");
const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL);
// *LAPRAS* Change when Agni
const LLUUID LLSettingsWater::DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661");
//=========================================================================
LLSettingsWater::LLSettingsWater(const LLSD &data) :

View File

@ -48,6 +48,8 @@ public:
static const LLUUID DEFAULT_WATER_NORMAL_ID;
static const LLUUID DEFAULT_ASSET_ID;
typedef std::shared_ptr<LLSettingsWater> ptr_t;
//---------------------------------------------------------------------

View File

@ -238,6 +238,16 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f);
const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f);
const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f);
//*TODO* Change these when available on Agni (these are Damballah asset IDs).
const LLUUID LLEnvironment::KNOWN_SKY_DEFAULT(LLSettingsSky::DEFAULT_ASSET_ID);
const LLUUID LLEnvironment::KNOWN_WATER_DEFAULT(LLSettingsWater::DEFAULT_ASSET_ID);
const LLUUID LLEnvironment::KNOWN_DAY_DEFAULT(LLSettingsDay::DEFAULT_ASSET_ID);
const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("645d7475-19d6-d05c-6eb2-29eeacf76e06");
const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("68f5a7ec-2785-d9d8-be7c-cca93976759a");
const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("06420773-757b-4b7c-a1f9-85fceb2f7bd4");
const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("c13658f3-91b8-d559-3a12-b11ce3940c4c");
const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg
const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS);
@ -498,6 +508,25 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe
}
}
void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId)
{
LLSettingsVOBase::getSettingsAsset(assetId,
[this, env](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, status); });
}
void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status)
{
if (!settings || status)
{
LLSD args;
args["DESC"] = asset_id.asString();
LLNotificationsUtil::add("FailedToFindSettings", args);
return;
}
setEnvironment(env, settings);
}
void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env)
{
@ -1311,196 +1340,172 @@ std::string LLEnvironment::getUserDir(const std::string &subdir)
LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename)
{
LLSD data = legacyLoadPreset(filename);
if (!data)
return LLSettingsWater::ptr_t();
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true));
LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data);
std::string path(gDirUtilp->getDirName(filename));
LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path);
return water;
}
LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename)
{
LLSD data = legacyLoadPreset(filename);
if (!data)
return LLSettingsSky::ptr_t();
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true));
LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data);
std::string path(gDirUtilp->getDirName(filename));
LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path);
return sky;
}
LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename)
{
// for the moment just look it up from the preloaded.
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true));
std::string path(gDirUtilp->getDirName(filename));
LLSettingsDay::ptr_t day = instance().findDayCycleByName(name);
LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path);
return day;
}
LLSD LLEnvironment::legacyLoadPreset(const std::string& path)
{
llifstream xml_file;
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true));
xml_file.open(path.c_str());
if (!xml_file)
{
return LLSD();
}
LLSD params_data;
LLPointer<LLSDParser> parser = new LLSDXMLParser();
parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED);
xml_file.close();
return params_data;
}
void LLEnvironment::legacyLoadAllPresets()
{
std::string dir;
std::string file;
// System skies
{
dir = getSysDir("skies");
LLDirIterator dir_iter(dir, "*.xml");
while (dir_iter.next(file))
{
std::string path = gDirUtilp->add(dir, file);
LLSD data = legacyLoadPreset(path);
if (data)
{
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data);
LLEnvironment::instance().addSky(sky);
}
}
}
// User skies
{
dir = getUserDir("skies");
LLDirIterator dir_iter(dir, "*.xml");
while (dir_iter.next(file))
{
std::string path = gDirUtilp->add(dir, file);
LLSD data = legacyLoadPreset(path);
if (data)
{
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data);
LLEnvironment::instance().addSky(sky);
}
}
}
// System water
{
dir = getSysDir("water");
LLDirIterator dir_iter(dir, "*.xml");
while (dir_iter.next(file))
{
std::string path = gDirUtilp->add(dir, file);
LLSD data = legacyLoadPreset(path);
if (data)
{
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data);
LLEnvironment::instance().addWater(water);
}
}
}
// User water
{
dir = getUserDir("water");
LLDirIterator dir_iter(dir, "*.xml");
while (dir_iter.next(file))
{
std::string path = gDirUtilp->add(dir, file);
LLSD data = legacyLoadPreset(path);
if (data)
{
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data);
LLEnvironment::instance().addWater(water);
}
}
}
// System Days
{
dir = getSysDir("days");
LLDirIterator dir_iter(dir, "*.xml");
while (dir_iter.next(file))
{
std::string path = gDirUtilp->add(dir, file);
LLSD data = legacyLoadPreset(path);
if (data)
{
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data);
/*if (day->validate())
{
LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL;
LLEnvironment::instance().addDayCycle(day);
}
else
{
LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL;
}*/
LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL;
LLEnvironment::instance().addDayCycle(day);
#ifdef EXPORT_PRESETS
std::string exportfile = LLURI::escape(name) + "(new).xml";
std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile);
LLSD settings = day->getSettings();
std::ofstream daycyclefile(exportpath);
LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY);
daycyclefile.close();
#endif
}
}
}
// User Days
{
dir = getUserDir("days");
LLDirIterator dir_iter(dir, "*.xml");
while (dir_iter.next(file))
{
std::string path = gDirUtilp->add(dir, file);
LLSD data = legacyLoadPreset(path);
if (data)
{
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data);
LLEnvironment::instance().addDayCycle(day);
}
}
}
// std::string dir;
// std::string file;
//
// // System skies
// {
// dir = getSysDir("skies");
// LLDirIterator dir_iter(dir, "*.xml");
// while (dir_iter.next(file))
// {
// std::string path = gDirUtilp->add(dir, file);
//
// LLSD data = legacyLoadPreset(path);
// if (data)
// {
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
//
// LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data);
// LLEnvironment::instance().addSky(sky);
// }
// }
// }
//
// // User skies
// {
// dir = getUserDir("skies");
// LLDirIterator dir_iter(dir, "*.xml");
// while (dir_iter.next(file))
// {
// std::string path = gDirUtilp->add(dir, file);
//
// LLSD data = legacyLoadPreset(path);
// if (data)
// {
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
//
// LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data);
// LLEnvironment::instance().addSky(sky);
// }
// }
// }
//
// // System water
// {
// dir = getSysDir("water");
// LLDirIterator dir_iter(dir, "*.xml");
// while (dir_iter.next(file))
// {
// std::string path = gDirUtilp->add(dir, file);
//
// LLSD data = legacyLoadPreset(path);
// if (data)
// {
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
//
// LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data);
// LLEnvironment::instance().addWater(water);
// }
// }
// }
//
// // User water
// {
// dir = getUserDir("water");
// LLDirIterator dir_iter(dir, "*.xml");
// while (dir_iter.next(file))
// {
// std::string path = gDirUtilp->add(dir, file);
//
// LLSD data = legacyLoadPreset(path);
// if (data)
// {
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
//
// LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data);
// LLEnvironment::instance().addWater(water);
// }
// }
// }
//
// // System Days
// {
// dir = getSysDir("days");
// LLDirIterator dir_iter(dir, "*.xml");
// while (dir_iter.next(file))
// {
// std::string path = gDirUtilp->add(dir, file);
//
// LLSD data = legacyLoadPreset(path);
// if (data)
// {
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
//
// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data);
// /*if (day->validate())
// {
// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL;
// LLEnvironment::instance().addDayCycle(day);
// }
// else
// {
// LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL;
// }*/
// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL;
// LLEnvironment::instance().addDayCycle(day);
// #ifdef EXPORT_PRESETS
// std::string exportfile = LLURI::escape(name) + "(new).xml";
// std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile);
//
// LLSD settings = day->getSettings();
//
// std::ofstream daycyclefile(exportpath);
// LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
// formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY);
// daycyclefile.close();
// #endif
// }
// }
// }
//
// // User Days
// {
// dir = getUserDir("days");
// LLDirIterator dir_iter(dir, "*.xml");
// while (dir_iter.next(file))
// {
// std::string path = gDirUtilp->add(dir, file);
//
// LLSD data = legacyLoadPreset(path);
// if (data)
// {
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
//
// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data);
// LLEnvironment::instance().addDayCycle(day);
// }
// }
// }
}
void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos)
@ -1521,9 +1526,6 @@ void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos)
S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude)
{
// //*LAPRAS* temp base on region's response.
// return llmin((static_cast<S32>(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1));
auto it = std::find_if_not(mTrackAltitudes.begin(), mTrackAltitudes.end(), [altitude](F32 test) { return altitude > test; });
if (it == mTrackAltitudes.begin())

View File

@ -55,6 +55,14 @@ public:
static const F32Seconds TRANSITION_SLOW;
static const F32Seconds TRANSITION_ALTITUDE;
static const LLUUID KNOWN_SKY_DEFAULT;
static const LLUUID KNOWN_WATER_DEFAULT;
static const LLUUID KNOWN_DAY_DEFAULT;
static const LLUUID KNOWN_SKY_SUNRISE;
static const LLUUID KNOWN_SKY_MIDDAY;
static const LLUUID KNOWN_SKY_SUNSET;
static const LLUUID KNOWN_SKY_MIDNIGHT;
struct EnvironmentInfo
{
EnvironmentInfo();
@ -159,6 +167,8 @@ public:
void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); }
void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); }
void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw)); }
void setEnvironment(EnvSelection_t env, const LLUUID &assetId);
void clearEnvironment(EnvSelection_t env);
LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env);
S64Seconds getEnvironmentDayLength(EnvSelection_t env);
@ -177,9 +187,11 @@ public:
list_name_id_t getWaterList() const;
list_name_id_t getDayCycleList() const;
// *LAPRAS* TODO : Remove these vvv
LLSettingsSky::ptr_t findSkyByName(std::string name) const;
LLSettingsWater::ptr_t findWaterByName(std::string name) const;
LLSettingsDay::ptr_t findDayCycleByName(std::string name) const;
// *LAPRAS* TODO : Remove these ^^^
inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; }
@ -376,9 +388,10 @@ private:
void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment);
void onAgentPositionHasChanged(const LLVector3 &localpos);
void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status);
//=========================================================================
void legacyLoadAllPresets();
static LLSD legacyLoadPreset(const std::string& path);
static std::string getSysDir(const std::string &subdir);
static std::string getUserDir(const std::string &subdir);

View File

@ -795,6 +795,14 @@ void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId)
void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status)
{
if (!settings || status)
{
LLSD args;
args["DESC"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown";
LLNotificationsUtil::add("FailedToFindSettings", args);
closeFloater();
return;
}
mEditDay = std::dynamic_pointer_cast<LLSettingsDay>(settings);
updateEditEnvironment();
syncronizeTabs();

View File

@ -122,6 +122,7 @@ void LLFloaterEnvironmentSettings::onSelectDayCyclePreset()
void LLFloaterEnvironmentSettings::onBtnOK()
{
#if 0
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
@ -157,7 +158,6 @@ void LLFloaterEnvironmentSettings::onBtnOK()
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
#if 0
// Save and apply new user preferences.
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;

View File

@ -212,6 +212,15 @@ void LLFloaterFixedEnvironment::loadInventoryItem(const LLUUID &inventoryId)
void LLFloaterFixedEnvironment::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status)
{
if (!settings || status)
{
LLSD args;
args["DESC"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown";
LLNotificationsUtil::add("FailedToFindSettings", args);
closeFloater();
return;
}
mSettings = settings;
updateEditEnvironment();
syncronizeTabs();

View File

@ -6903,7 +6903,44 @@ LLUIImagePtr LLSettingsBridge::getIcon() const
void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action)
{
LLItemBridge::performAction(model, action);
if ("apply_settings_local" == action)
{
// Single item only
LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem());
if (!item)
return;
LLUUID asset_id = item->getProtectedAssetUUID();
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, asset_id);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if ("apply_settings_parcel" == action)
{
// Single item only
LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem());
if (!item)
return;
LLUUID asset_id = item->getProtectedAssetUUID();
// *LAPRAS* TODO update on simulator.
LL_WARNS("LAPRAS") << "Only updating locally!!! NOT REALLY PARCEL UPDATE" << LL_ENDL;
LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_PARCEL, asset_id);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if ("apply_settings_region" == action)
{
// Single item only
LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem());
if (!item)
return;
LLUUID asset_id = item->getProtectedAssetUUID();
// *LAPRAS* TODO update on simulator.
LL_WARNS("LAPRAS") << "Only updating locally!!! NOT REALLY REGION UPDATE" << LL_ENDL;
LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, asset_id);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else
LLItemBridge::performAction(model, action);
}
void LLSettingsBridge::openItem()
@ -6917,9 +6954,48 @@ void LLSettingsBridge::openItem()
void LLSettingsBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
LLItemBridge::buildContextMenu(menu, flags);
}
LL_DEBUGS() << "LLSettingsBridge::buildContextMenu()" << LL_ENDL;
menuentry_vec_t items;
menuentry_vec_t disabled_items;
if (isMarketplaceListingsFolder())
{
menuentry_vec_t items;
menuentry_vec_t disabled_items;
addMarketplaceContextMenuOptions(flags, items, disabled_items);
items.push_back(std::string("Properties"));
getClipboardEntries(false, items, disabled_items, flags);
hide_context_entries(menu, items, disabled_items);
}
else if (isItemInTrash())
{
addTrashContextMenuOptions(items, disabled_items);
}
else
{
items.push_back(std::string("Share"));
if (!canShare())
{
disabled_items.push_back(std::string("Share"));
}
addOpenRightClickMenuOption(items);
items.push_back(std::string("Properties"));
getClipboardEntries(true, items, disabled_items, flags);
items.push_back("Settings Separator");
items.push_back("Settings Apply Local");
items.push_back("Settings Apply Parcel");
// *LAPRAS* TODO: test for permission
items.push_back("Settings Apply Region");
// *LAPRAS* TODO: test for permission
}
addLinkReplaceMenuOption(items, disabled_items);
hide_context_entries(menu, items, disabled_items);
}
std::string LLSettingsBridge::getLabelSuffix() const
{
return LLItemBridge::getLabelSuffix();

View File

@ -58,47 +58,33 @@
#include "llassetstorage.h"
#include "llvfile.h"
#include <boost/algorithm/string/replace.hpp>
#undef VERIFY_LEGACY_CONVERSION
//=========================================================================
namespace
{
LLSD ensureArray4(LLSD in, F32 fill)
{
if (in.size() >= 4)
return in;
LLSD out(LLSD::emptyArray());
for (S32 idx = 0; idx < in.size(); ++idx)
LLSD ensure_array_4(LLSD in, F32 fill);
LLSD read_legacy_preset_data(const std::string& path);
//-------------------------------------------------------------------------
class LLSettingsInventoryCB : public LLInventoryCallback
{
out.append(in[idx]);
}
while (out.size() < 4)
{
out.append(LLSD::Real(fill));
}
return out;
}
public:
typedef std::function<void(const LLUUID &)> callback_t;
LLSettingsInventoryCB(callback_t cbfn) :
mCbfn(cbfn)
{ }
//-------------------------------------------------------------------------
class LLSettingsInventoryCB : public LLInventoryCallback
{
public:
typedef std::function<void(const LLUUID &)> callback_t;
void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); }
LLSettingsInventoryCB(callback_t cbfn) :
mCbfn(cbfn)
{ }
void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); }
private:
callback_t mCbfn;
};
private:
callback_t mCbfn;
};
//-------------------------------------------------------------------------
}
@ -240,9 +226,10 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i
}
else
{
LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL;
LL_WARNS("SETTINGS") << "Error retrieving asset " << asset_id << ". Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL;
}
callback(asset_id, settings, status, ext_status);
if (callback)
callback(asset_id, settings, status, ext_status);
}
@ -392,6 +379,37 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n
return skyp;
}
namespace
{
// This is a disturbing hack
std::string legacy_name_to_filename(const std::string &name)
{
std::string fixedname(LLURI::escape(name));
boost::algorithm::replace_all(fixedname, "-", "%2D");
return fixedname;
}
}
LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path)
{
std::string full_path(path);
std::string full_name(legacy_name_to_filename(name));
full_name += ".xml";
gDirUtilp->append(full_path, full_name);
LLSD legacy_data = read_legacy_preset_data(full_path);
if (!legacy_data)
{
LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL;
return ptr_t();
}
return buildFromLegacyPreset(name, legacy_data);
}
LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky()
{
LLSD settings = LLSettingsSky::defaults();
@ -429,9 +447,9 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings)
{
// LEGACY_ATMOSPHERICS
// These will need to be inferred from new settings' density profiles
legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f);
legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0);
legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0);
legacy[SETTING_AMBIENT] = ensure_array_4(settings[SETTING_AMBIENT], 1.0f);
legacy[SETTING_BLUE_DENSITY] = ensure_array_4(settings[SETTING_BLUE_DENSITY], 1.0);
legacy[SETTING_BLUE_HORIZON] = ensure_array_4(settings[SETTING_BLUE_HORIZON], 1.0);
legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f);
legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f);
legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f);
@ -453,20 +471,20 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA
convertAtmosphericsToLegacy(legacy, settings);
legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0);
legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0);
legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0);
legacy[SETTING_CLOUD_COLOR] = ensure_array_4(settings[SETTING_CLOUD_COLOR], 1.0);
legacy[SETTING_CLOUD_POS_DENSITY1] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0);
legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0);
legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0));
legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE];
legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal())))
(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal())));
legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f);
legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f);
legacy[SETTING_GLOW] = ensureArray4(settings[SETTING_GLOW], 1.0);
legacy[SETTING_LIGHT_NORMAL] = ensureArray4(psky->getLightDirection().getValue(), 0.0f);
legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0);
legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f);
legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f);
legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS];
legacy[SETTING_SUNLIGHT_COLOR] = ensureArray4(settings[SETTING_SUNLIGHT_COLOR], 1.0f);
legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f);
LLSettingsSky::azimalt_t azialt = psky->getSunRotationAzAl();
@ -595,6 +613,25 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin
return waterp;
}
LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path)
{
std::string full_path(path);
std::string full_name(legacy_name_to_filename(name));
full_name += ".xml";
gDirUtilp->append(full_path, full_name);
LLSD legacy_data = read_legacy_preset_data(full_path);
if (!legacy_data)
{
LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL;
return ptr_t();
}
return buildFromLegacyPreset(name, legacy_data);
}
LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater()
{
LLSD settings = LLSettingsWater::defaults();
@ -635,7 +672,7 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater)
LLSD settings = pwater->getSettings();
legacy[SETTING_LEGACY_BLUR_MULTIPILER] = settings[SETTING_BLUR_MULTIPILER];
legacy[SETTING_LEGACY_FOG_COLOR] = ensureArray4(settings[SETTING_FOG_COLOR], 1.0f);
legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f);
legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY];
legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD];
legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET];
@ -740,10 +777,18 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings)
}
//-------------------------------------------------------------------------
LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings)
LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings)
{
LLSD newsettings(defaults());
std::set<std::string> framenames;
std::set<std::string> notfound;
std::string base_path(gDirUtilp->getDirName(path));
std::string water_path(base_path);
std::string sky_path(base_path);
gDirUtilp->append(water_path, "water");
gDirUtilp->append(sky_path, "skies");
newsettings[SETTING_NAME] = name;
@ -767,14 +812,16 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n
LLSD frames(LLSD::emptyMap());
{
LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName("Default");
frames["water:Default"] = pwater->getSettings();
LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path);
if (pwater)
frames["water:Default"] = pwater->getSettings();
}
for (std::set<std::string>::iterator itn = framenames.begin(); itn != framenames.end(); ++itn)
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(*itn);
frames["sky:" + (*itn)] = psky->getSettings();
LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path);
if (psky)
frames["sky:" + (*itn)] = psky->getSettings();
}
newsettings[SETTING_FRAMES] = frames;
@ -806,6 +853,26 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n
return dayp;
}
LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path)
{
std::string full_path(path);
std::string full_name(legacy_name_to_filename(name));
full_name += ".xml";
gDirUtilp->append(full_path, full_name);
LLSD legacy_data = read_legacy_preset_data(full_path);
if (!legacy_data)
{
LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL;
return ptr_t();
}
return buildFromLegacyPreset(name, path, legacy_data);
}
LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID &regionId, LLSD daycycle, LLSD skydefs, LLSD waterdef)
{
LLSD frames(LLSD::emptyMap());
@ -863,6 +930,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID &regio
return dayp;
}
LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle()
{
LLSD settings = LLSettingsDay::defaults();
@ -996,12 +1065,43 @@ LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const
return LLSettingsWater::ptr_t();
}
LLSettingsSkyPtr_t LLSettingsVODay::getNamedSky(const std::string &name) const
//=========================================================================
namespace
{
return LLEnvironment::instance().findSkyByName(name);
}
LLSD ensure_array_4(LLSD in, F32 fill)
{
if (in.size() >= 4)
return in;
LLSettingsWaterPtr_t LLSettingsVODay::getNamedWater(const std::string &name) const
{
return LLEnvironment::instance().findWaterByName(name);
LLSD out(LLSD::emptyArray());
for (S32 idx = 0; idx < in.size(); ++idx)
{
out.append(in[idx]);
}
while (out.size() < 4)
{
out.append(LLSD::Real(fill));
}
return out;
}
//---------------------------------------------------------------------
LLSD read_legacy_preset_data(const std::string& path)
{
llifstream xml_file;
// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true));
xml_file.open(path.c_str());
if (!xml_file)
return LLSD();
LLSD params_data;
LLPointer<LLSDParser> parser = new LLSDXMLParser();
parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED);
xml_file.close();
return params_data;
}
}

View File

@ -90,6 +90,8 @@ public:
static ptr_t buildDefaultSky();
virtual ptr_t buildClone() override;
static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path);
static LLSD convertToLegacy(const ptr_t &, bool isAdvanced);
bool isAdvanced() const { return m_isAdvanced; }
@ -121,6 +123,8 @@ public:
static ptr_t buildDefaultWater();
virtual ptr_t buildClone() override;
static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path);
static LLSD convertToLegacy(const ptr_t &);
protected:
LLSettingsVOWater();
@ -144,7 +148,8 @@ public:
static ptr_t buildDay(LLSD settings);
static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings);
static ptr_t buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings);
static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path);
static ptr_t buildFromLegacyMessage(const LLUUID &regionId, LLSD daycycle, LLSD skys, LLSD water);
static ptr_t buildDefaultDayCycle();
static ptr_t buildFromEnvironmentMessage(LLSD settings);
@ -156,8 +161,6 @@ public:
virtual LLSettingsWaterPtr_t getDefaultWater() const override;
virtual LLSettingsSkyPtr_t buildSky(LLSD) const override;
virtual LLSettingsWaterPtr_t buildWater(LLSD) const override;
virtual LLSettingsSkyPtr_t getNamedSky(const std::string &) const override;
virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const override;
protected:
LLSettingsVODay();

View File

@ -8391,26 +8391,22 @@ class LLWorldEnvSettings : public view_listener_t
if (tod == "sunrise")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunrise");
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNRISE);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "noon")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midday");
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDDAY);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "sunset")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunset");
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNSET);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "midnight")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midnight");
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDNIGHT);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else

View File

@ -862,6 +862,33 @@
<menu_item_call.on_click
function="Inventory.DoToSelected"
parameter="take_off" />
</menu_item_call>
<menu_item_separator
layout="topleft"
name="Settings Separator" />
<menu_item_call
name="Settings Apply Local"
layout="topleft"
label="Apply Only To Myself">
<menu_item_call.on_click
function="Inventory.DoToSelected"
parameter="apply_settings_local" />
</menu_item_call>
<menu_item_call
name="Settings Apply Parcel"
layout="topleft"
label="Apply To Parcel">
<menu_item_call.on_click
function="Inventory.DoToSelected"
parameter="apply_settings_parcel" />
</menu_item_call>
<menu_item_call
name="Settings Apply Region"
layout="topleft"
label="Apply To Region">
<menu_item_call.on_click
function="Inventory.DoToSelected"
parameter="apply_settings_region" />
</menu_item_call>
<menu_item_separator
layout="topleft"

View File

@ -28,14 +28,14 @@
</menu_item_call>
<menu_item_call
name="apply_parcel"
label="Apply Parcel">
label="Apply To Parcel">
<menu_item_call.on_click
function="FlyoutCombo.Button.Action"
userdata="parcel" />
</menu_item_call>
<menu_item_call
name="apply_region"
label="Apply Region">
label="Apply To Region">
<menu_item_call.on_click
function="FlyoutCombo.Button.Action"
userdata="region" />

View File

@ -11104,4 +11104,13 @@ Cannot create large prims that intersect other players. Please re-try when othe
yestext="OK"/>
</notification>
<notification
icon="notify.tga"
name="FailedToFindSettings"
persist="true"
type="alertmodal">
Failed to find the settisgs named [DESC] in database.
<tag>fail</tag>
</notification>
</notifications>