diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llenvironment.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 1 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.cpp | 191 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.h | 18 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml | 10 | ||||
-rw-r--r-- | indra/newview/tests/lldateutil_test.cpp | 2 | ||||
-rw-r--r-- | indra/newview/tests/llworldmap_test.cpp | 2 |
9 files changed, 195 insertions, 45 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index cfea83c788..9bc3f65c79 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1265,6 +1265,16 @@ LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string 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)); + + LLSettingsDay::ptr_t day = instance().findDayCycleByName(name); + return day; +} + + LLSD LLEnvironment::legacyLoadPreset(const std::string& path) { llifstream xml_file; diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 9f9eb614a4..e8e5a74196 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -194,6 +194,7 @@ public: static LLSettingsWater::ptr_t createWaterFromLegacyPreset(const std::string filename); static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename); + static LLSettingsDay::ptr_t createDayCycleFromLegacyPreset(const std::string filename); //------------------------------------------- connection_t setSkyListChange(const change_signal_t::slot_type& cb); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index d87ea83fe7..e578b5db9a 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -39,11 +39,15 @@ #include "llspinctrl.h" #include "lltimectrl.h" #include "lltabcontainer.h" +#include "llfilepicker.h" #include "llsettingsvo.h" #include "llinventorymodel.h" +#include "llviewerparcelmgr.h" + // newview #include "llagent.h" +#include "llparcel.h" #include "llflyoutcombobtn.h" //Todo: make a proper UI element/button/panel instead #include "llregioninfomodel.h" #include "llviewerregion.h" @@ -90,6 +94,7 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): mFramesSlider(NULL), mCurrentTimeLabel(NULL), // **RIDER** + mImportButton(nullptr), mInventoryId(), mInventoryItem(nullptr), mSkyBlender(), @@ -124,6 +129,7 @@ BOOL LLFloaterEditExtDayCycle::postBuild() mSkyTabLayoutContainer = getChild<LLView>("frame_settings_sky", true); mWaterTabLayoutContainer = getChild<LLView>("frame_settings_water", true); mCurrentTimeLabel = getChild<LLTextBox>("current_time", true); + mImportButton = getChild<LLButton>("btn_import", true); mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE); mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); @@ -133,6 +139,7 @@ BOOL LLFloaterEditExtDayCycle::postBuild() mFramesSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onFrameSliderCallback, this)); mAddFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this)); mDeleteFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onRemoveTrack, this)); + mImportButton->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonImport(); }); mTimeSlider->addSlider(0); @@ -174,9 +181,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) // **RIDER** - LLLineEditor* name_field = getChild<LLLineEditor>("day_cycle_name"); - name_field->setText(mEditDay->getName()); - selectTrack(mCurrentTrack); // time labels @@ -237,54 +241,45 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility) } } +void LLFloaterEditExtDayCycle::refresh() +{ + if (mEditDay) + { + LLLineEditor* name_field = getChild<LLLineEditor>("day_cycle_name"); + name_field->setText(mEditDay->getName()); + } + + bool is_inventory_avail = canUseInventory(); + + mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail); + mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, is_inventory_avail); + + + LLFloater::refresh(); +} + + void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) { std::string ctrl_action = ctrl->getName(); if (ctrl_action == ACTION_SAVE) { -// if (mSavedDay.get() != mOriginalDay.get()) -// { -// restoreSavedEnv(); -// } -// else -// { -// S64Seconds day_length = mDayLength.value() > 0 ? mDayLength : LLSettingsDay::DEFAULT_DAYLENGTH; -// S64Seconds day_offset = mDayLength.value() > 0 ? mDayOffset : LLSettingsDay::DEFAULT_DAYOFFSET; -// LLEnvironment::instance().setEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment, mEditDay, day_length, day_offset); -// LLEnvironment::instance().setSelectedEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment); -// LLEnvironment::instance().updateEnvironment(); -// } -// mOriginalDay = mEditDay; // to kill the pointer -// -// if (!mCommitSignal.empty()) -// mCommitSignal(mEditDay); + doApplyUpdateInventory(); } else if (ctrl_action == ACTION_SAVEAS) { - LLSettingsVOBase::createInventoryItem(mEditDay); + doApplyCreateNewInventory(); + } + else if ((ctrl_action == ACTION_APPLY_LOCAL) || + (ctrl_action == ACTION_APPLY_PARCEL) || + (ctrl_action == ACTION_APPLY_REGION)) + { + doApplyEnvironment(ctrl_action); } else { - LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT); - bool updateSimulator(ctrl_action != ACTION_APPLY_LOCAL); - - if (ctrl_action == ACTION_APPLY_LOCAL) - env = LLEnvironment::ENV_LOCAL; - else if (ctrl_action == ACTION_APPLY_PARCEL) - env = LLEnvironment::ENV_PARCEL; - else if (ctrl_action == ACTION_APPLY_REGION) - env = LLEnvironment::ENV_REGION; - else - { - LL_WARNS("ENVIRONMENT") << "Unknown apply '" << ctrl_action << "'" << LL_ENDL; - } - - LLEnvironment::instance().setEnvironment(env, mEditDay); - if (updateSimulator) - { - LL_WARNS("ENVIRONMENT") << "Attempting to apply " << env << LL_ENDL; - } + LL_WARNS("ENVIRONMENT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL; } } @@ -293,6 +288,11 @@ void LLFloaterEditExtDayCycle::onBtnCancel() closeFloater(); // will restore env } +void LLFloaterEditExtDayCycle::onButtonImport() +{ + doImportFromDisk(); +} + void LLFloaterEditExtDayCycle::onAddTrack() { // todo: 2.5% safety zone @@ -759,6 +759,12 @@ void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t } } + if (!mEditDay) + { + LL_WARNS("SETTINGS") << "Unable to load environment " << env << " building default." << LL_ENDL; + mEditDay = LLSettingsVODay::buildDefaultDayCycle(); + } + updateEditEnvironment(); syncronizeTabs(); refresh(); @@ -859,6 +865,113 @@ void LLFloaterEditExtDayCycle::reblendSettings() mWaterBlender->setPosition(position); } +void LLFloaterEditExtDayCycle::doApplyCreateNewInventory() +{ + // This method knows what sort of settings object to create. + LLSettingsVOBase::createInventoryItem(mEditDay, [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); +} + +void LLFloaterEditExtDayCycle::doApplyUpdateInventory() +{ + if (mInventoryId.isNull()) + LLSettingsVOBase::createInventoryItem(mEditDay, [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + else + LLSettingsVOBase::updateInventoryItem(mEditDay, mInventoryId, [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryUpdated(asset_id, inventory_id, results); }); +} + +void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where) +{ + LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT); + bool updateSimulator(where != ACTION_APPLY_LOCAL); + + if (where == ACTION_APPLY_LOCAL) + env = LLEnvironment::ENV_LOCAL; + else if (where == ACTION_APPLY_PARCEL) + env = LLEnvironment::ENV_PARCEL; + else if (where == ACTION_APPLY_REGION) + env = LLEnvironment::ENV_REGION; + else + { + LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; + return; + } + + LLEnvironment::instance().setEnvironment(env, mEditDay); + if (updateSimulator) + { + LL_WARNS("ENVIRONMENT") << "Attempting apply" << LL_ENDL; + } +} + +void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ + LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; + + setFocus(TRUE); // Call back the focus... + loadInventoryItem(inventory_id); +} + +void LLFloaterEditExtDayCycle::onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ + LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been updated with asset " << asset_id << " results are:" << results << LL_ENDL; + + if (inventory_id != mInventoryId) + { + loadInventoryItem(inventory_id); + } +} + +void LLFloaterEditExtDayCycle::doImportFromDisk() +{ // Load a a legacy Windlight XML from disk. + + LLFilePicker& picker = LLFilePicker::instance(); + if (picker.getOpenFile(LLFilePicker::FFLOAD_XML)) + { + std::string filename = picker.getFirstFile(); + + LL_WARNS("LAPRAS") << "Selected file: " << filename << LL_ENDL; + LLSettingsDay::ptr_t legacyday = LLEnvironment::createDayCycleFromLegacyPreset(filename); + + if (!legacyday) + { // *TODO* Put up error dialog here. Could not create water from filename + return; + } + + mEditDay = legacyday; + + updateEditEnvironment(); + syncronizeTabs(); + refresh(); + } +} + +bool LLFloaterEditExtDayCycle::canUseInventory() const +{ + return LLEnvironment::instance().isInventoryEnabled(); +} + +bool LLFloaterEditExtDayCycle::canApplyRegion() const +{ + return gAgent.canManageEstate(); +} + +bool LLFloaterEditExtDayCycle::canApplyParcel() const +{ + LLParcelSelectionHandle handle(LLViewerParcelMgr::instance().getParcelSelection()); + LLParcel *parcel(nullptr); + + if (handle) + parcel = handle->getParcel(); + if (!parcel) + parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (!parcel) + return false; + + return parcel->allowModifyBy(gAgent.getID(), gAgent.getGroupID()) && + LLEnvironment::instance().isExtendedEnvironmentEnabled(); +} + // **RIDER** diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 287d2fe2dc..3a1f29382a 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -75,12 +75,15 @@ public: connection_t setEditCommitSignal(edit_commit_signal_t::slot_type cb); + virtual void refresh(); + private: // flyout response/click void onButtonApply(LLUICtrl *ctrl, const LLSD &data); void onBtnCancel(); - void onAddTrack(); + void onButtonImport(); + void onAddTrack(); void onRemoveTrack(); void onCommitName(class LLLineEditor* caller, void* user_data); void onTrackSelectionCallback(const LLSD& user_data); @@ -107,9 +110,21 @@ private: void onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); void loadLiveEnvironment(LLEnvironment::EnvSelection_t env); + void doImportFromDisk(); + void doApplyCreateNewInventory(); + void doApplyUpdateInventory(); + void doApplyEnvironment(const std::string &where); + void onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + void onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + + bool canUseInventory() const; + bool canApplyRegion() const; + bool canApplyParcel() const; + void updateEditEnvironment(); void syncronizeTabs(); void reblendSettings(); + // **RIDER** // data for restoring previous displayed environment @@ -125,6 +140,7 @@ private: LLButton* mCancelButton; LLButton* mAddFrameButton; LLButton* mDeleteFrameButton; + LLButton* mImportButton; LLMultiSliderCtrl* mTimeSlider; LLMultiSliderCtrl* mFramesSlider; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 699370cad3..2b74116f8b 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -7293,7 +7293,7 @@ public: LLFloaterReg::showInstance("env_fixed_environmentent_water", LLSDMap("inventory_id", item->getUUID()), TAKE_FOCUS_YES); break; case LLSettingsType::ST_DAYCYCLE: - //LLFloaterReg::showInstance("env_fixed_environmentent_day", LLSDMap("inventory_id", item->getUUID()), TAKE_FOCUS_YES); + LLFloaterReg::showInstance("env_edit_extdaycycle", LLSDMap("inventory_id", item->getUUID()), TAKE_FOCUS_YES); break; default: break; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ec0cbb3482..ce1e740425 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8493,11 +8493,11 @@ class LLWorldEnvPreset : public view_listener_t } else if (item == "new_day_cycle") { - LLFloaterReg::showInstance("env_edit_day_cycle", "new"); + LLFloaterReg::showInstance("env_edit_extdaycycle", "new"); } else if (item == "edit_day_cycle") { - LLFloaterReg::showInstance("env_edit_day_cycle", "edit"); + LLFloaterReg::showInstance("env_edit_extdaycycle", "edit"); } else { diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index ba4e15e7db..c4de2cdaee 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -52,6 +52,16 @@ top="5" width="200" height="21" /> + <button + height="23" + label="Import" + follows="right|top" + right="-10" + font="SansSerif" + top_delta="0" + name="btn_import" + tool_tip="Import legacy settings from disk." + width="96" /> </layout_panel> <layout_panel name="timeline_track_selection" border="false" diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index 47353962e1..e1365aef1c 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -45,7 +45,7 @@ std::map< std::string, std::string > gString; typedef std::pair< std::string, int > count_string_t; std::map< count_string_t, std::string > gCountString; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) +std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool) { std::string text = gString[xml_desc]; LLStringUtil::format(text, args); diff --git a/indra/newview/tests/llworldmap_test.cpp b/indra/newview/tests/llworldmap_test.cpp index 84194adb5d..2ca190d459 100644 --- a/indra/newview/tests/llworldmap_test.cpp +++ b/indra/newview/tests/llworldmap_test.cpp @@ -66,7 +66,7 @@ void LLWorldMipmap::equalizeBoostLevels() { } LLPointer<LLViewerFetchedTexture> LLWorldMipmap::getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load) { return NULL; } // Stub other stuff -std::string LLTrans::getString(const std::string &, const LLStringUtil::format_map_t& ) { return std::string("test_trans"); } +std::string LLTrans::getString(const std::string &, const LLStringUtil::format_map_t&, bool ) { return std::string("test_trans"); } void LLUIString::updateResult() const { } void LLUIString::setArg(const std::string& , const std::string& ) { } void LLUIString::assign(const std::string& ) { } |