diff options
author | Graham Linden <graham@lindenlab.com> | 2018-06-02 00:31:25 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-06-02 00:31:25 +0100 |
commit | 7d6743f42d09bfcc39c0930aa342638d8273b722 (patch) | |
tree | 1d221a9ef43d997e09801e3fdd2900f3c3cdf179 /indra/newview | |
parent | f87cf83a2bcca87f33c3f94cd09438fb7b65529c (diff) | |
parent | 2a613d7363c4e91a7258d4f0ea3971db1569e788 (diff) |
Merge
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llenvironment.cpp | 344 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 15 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llfloaterenvironmentsettings.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 82 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 202 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.h | 9 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 12 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_inventory.xml | 27 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_save_settings.xml | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 9 |
12 files changed, 483 insertions, 240 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b7aff6bca9..3b0bc4cd55 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -240,6 +240,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 //------------------------------------------------------------------------- @@ -554,6 +564,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) { @@ -1405,196 +1434,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) @@ -1615,9 +1620,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()) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 52f22ac8f1..56be88f371 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -56,6 +56,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(); @@ -162,6 +170,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); LLSettingsDay::Seconds getEnvironmentDayLength(EnvSelection_t env); @@ -180,9 +190,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; } @@ -387,9 +399,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); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 543f6e5671..cac9154c98 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -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(); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index b7bf6918fe..1b96db6611 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -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; diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index d5fc34a04b..6c1080294d 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -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(); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 2b74116f8b..fe7d302992 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -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(); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 451a0fb326..0e3bc87719 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -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) - { - out.append(in[idx]); - } - - while (out.size() < 4) - { - out.append(LLSD::Real(fill)); - } - return out; -} - + LLSD ensure_array_4(LLSD in, F32 fill); + LLSD read_legacy_preset_data(const std::string& path); -//------------------------------------------------------------------------- -class LLSettingsInventoryCB : public LLInventoryCallback -{ -public: - typedef std::function<void(const LLUUID &)> callback_t; + //------------------------------------------------------------------------- + class LLSettingsInventoryCB : public LLInventoryCallback + { + public: + typedef std::function<void(const LLUUID &)> callback_t; - LLSettingsInventoryCB(callback_t cbfn) : - mCbfn(cbfn) - { } + LLSettingsInventoryCB(callback_t cbfn) : + mCbfn(cbfn) + { } - void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } + 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(); @@ -449,20 +467,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); LLQuaternion sunquat = psky->getSunRotation(); @@ -619,6 +637,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(); @@ -659,7 +696,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]; @@ -768,10 +805,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; @@ -795,14 +840,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; @@ -834,6 +881,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 ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) { LLSD frames(LLSD::emptyMap()); @@ -891,6 +958,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io return dayp; } + + LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() { LLSD settings = LLSettingsDay::defaults(); @@ -1024,12 +1093,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; + } } diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 2f91117858..7d68586fa0 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -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; } @@ -122,6 +124,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(); @@ -145,7 +149,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 ®ionId, LLSD daycycle, LLSD skys, LLSD water); static ptr_t buildDefaultDayCycle(); static ptr_t buildFromEnvironmentMessage(LLSD settings); @@ -157,8 +162,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(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ce1e740425..8153e41b45 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -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 diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index 29915788f1..edd1f42d92 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -863,6 +863,33 @@ 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" name="Marketplace Separator" /> diff --git a/indra/newview/skins/default/xui/en/menu_save_settings.xml b/indra/newview/skins/default/xui/en/menu_save_settings.xml index 0d52d9b16e..a72b02c593 100644 --- a/indra/newview/skins/default/xui/en/menu_save_settings.xml +++ b/indra/newview/skins/default/xui/en/menu_save_settings.xml @@ -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" /> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 6aa6653f42..d7193c511f 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -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> |