diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e51154aca6..e5a93232a1 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -412,6 +412,7 @@ set(viewer_SOURCE_FILES llfloaterregioninfo.cpp llfloaterreporter.cpp llfloaterregionrestarting.cpp + llfloatersavecamerapreset.cpp llfloatersaveprefpreset.cpp llfloatersceneloadstats.cpp llfloaterscriptdebug.cpp @@ -1176,6 +1177,7 @@ set(viewer_HEADER_FILES llfloaterregioninfo.h llfloaterreporter.h llfloaterregionrestarting.h + llfloatersavecamerapreset.h llfloatersaveprefpreset.h llfloatersceneloadstats.h llfloaterscriptdebug.h diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml index cb3380589e..e4839d48ec 100644 --- a/indra/newview/app_settings/camera/Front.xml +++ b/indra/newview/app_settings/camera/Front.xml @@ -63,6 +63,17 @@ Value 1 + CameraZoomFraction + + Comment + Mousewheel driven fraction of zoom + Persist + 1 + Type + F32 + Value + 0.9 + EditCameraMovement Comment diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml index 0bfe5a9ed8..72e6c5d93a 100644 --- a/indra/newview/app_settings/camera/Rear.xml +++ b/indra/newview/app_settings/camera/Rear.xml @@ -63,6 +63,17 @@ Value 1 + CameraZoomFraction + + Comment + Mousewheel driven fraction of zoom + Persist + 1 + Type + F32 + Value + 0.9 + EditCameraMovement Comment diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml index 49582a8a3c..eb3b3253c1 100644 --- a/indra/newview/app_settings/camera/Side.xml +++ b/indra/newview/app_settings/camera/Side.xml @@ -63,6 +63,17 @@ Value 1 + CameraZoomFraction + + Comment + Mousewheel driven fraction of zoom + Persist + 1 + Type + F32 + Value + 0.9 + EditCameraMovement Comment diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index b1fd83ba9a..8f082147bf 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -3061,6 +3061,17 @@ Value 1.0 + CameraZoomFraction + + Comment + Mousewheel driven fraction of zoom + Persist + 1 + Type + F32 + Value + 0.9 + CameraPosOnLogout Comment diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 517e4a2e40..6d00e329af 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -648,6 +648,7 @@ void LLFloaterCamera::switchToPreset(const std::string& name) { LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); } + gAgentCamera.setCameraZoomFraction(gSavedSettings.getF32("CameraZoomFraction")); LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); if (camera_floater) @@ -701,11 +702,10 @@ void LLFloaterCamera::onSavePreset() LLFloaterReg::hideInstance("load_pref_preset", PRESETS_CAMERA); LLSD key; - key["subdirectory"] = PRESETS_CAMERA; std::string current_preset = gSavedSettings.getString("PresetCameraActive"); bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultCameraPreset(current_preset); key["index"] = is_custom_preset ? 1 : 0; - LLFloaterReg::showInstance("save_pref_preset", key); + LLFloaterReg::showInstance("save_camera_preset", key); } void LLFloaterCamera::onCustomPresetSelected() diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 2056697c01..d28b384bc5 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -4202,26 +4202,17 @@ void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl) void LLPanelPreference::deletePreset(const LLSD& user_data) { - std::string subdirectory = user_data.asString(); - LLFloaterReg::hideInstance("load_pref_preset", subdirectory); - LLFloaterReg::hideInstance("save_pref_preset", subdirectory); - LLFloaterReg::showInstance("delete_pref_preset", subdirectory); + LLFloaterReg::showInstance("delete_pref_preset", user_data.asString()); } void LLPanelPreference::savePreset(const LLSD& user_data) { - std::string subdirectory = user_data.asString(); - LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); - LLFloaterReg::hideInstance("load_pref_preset", subdirectory); - LLFloaterReg::showInstance("save_pref_preset", subdirectory); + LLFloaterReg::showInstance("save_pref_preset", user_data.asString()); } void LLPanelPreference::loadPreset(const LLSD& user_data) { - std::string subdirectory = user_data.asString(); - LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); - LLFloaterReg::hideInstance("save_pref_preset", subdirectory); - LLFloaterReg::showInstance("load_pref_preset", subdirectory); + LLFloaterReg::showInstance("load_pref_preset", user_data.asString()); } void LLPanelPreference::setHardwareDefaults() diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp new file mode 100644 index 0000000000..5d62aff0e2 --- /dev/null +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -0,0 +1,153 @@ +/** + * @file llfloatersavecamerapreset.cpp + * @brief Floater to save a camera preset + * + * $LicenseInfo:firstyear=2020&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2020, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatersavecamerapreset.h" + +#include "llbutton.h" +#include "llcombobox.h" +#include "llfloaterpreference.h" +#include "llfloaterreg.h" +#include "lllineeditor.h" +#include "llnotificationsutil.h" +#include "llpresetsmanager.h" +#include "llradiogroup.h" +#include "lltrans.h" + +LLFloaterSaveCameraPreset::LLFloaterSaveCameraPreset(const LLSD &key) + : LLModalDialog(key) +{ +} + +// virtual +BOOL LLFloaterSaveCameraPreset::postBuild() +{ + mPresetCombo = getChild("preset_combo"); + + mNameEditor = getChild("preset_txt_editor"); + mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSaveCameraPreset::onPresetNameEdited, this), NULL); + + mSaveButton = getChild("save"); + mSaveButton->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onBtnSave, this)); + + mSaveRadioGroup = getChild("radio_save_preset"); + mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onSwitchSaveReplace, this)); + + getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onBtnCancel, this)); + + LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSaveCameraPreset::onPresetsListChange, this)); + + return TRUE; +} + +void LLFloaterSaveCameraPreset::onPresetNameEdited() +{ + if (mSaveRadioGroup->getSelectedIndex() == 0) + { + // Disable saving a preset having empty name. + std::string name = mNameEditor->getValue(); + mSaveButton->setEnabled(!name.empty()); + } +} + +void LLFloaterSaveCameraPreset::onOpen(const LLSD& key) +{ + LLModalDialog::onOpen(key); + S32 index = 0; + if (key.has("index")) + { + index = key["index"].asInteger(); + } + + LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_HIDE); + + mSaveRadioGroup->setSelectedIndex(index); + onPresetNameEdited(); + onSwitchSaveReplace(); +} + +void LLFloaterSaveCameraPreset::onBtnSave() +{ + bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; + std::string name = is_saving_new ? mNameEditor->getText() : mPresetCombo->getSimple(); + + if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT)) + { + LLNotificationsUtil::add("DefaultPresetNotSaved"); + } + else + { + if (is_saving_new) + { + std::list preset_names; + std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA); + LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE); + if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end()) + { + LLSD args; + args["NAME"] = name; + LLNotificationsUtil::add("PresetAlreadyExists", args); + return; + } + } + if (!LLPresetsManager::getInstance()->savePreset(PRESETS_CAMERA, name)) + { + LLSD args; + args["NAME"] = name; + LLNotificationsUtil::add("PresetNotSaved", args); + } + } + + closeFloater(); +} + +void LLFloaterSaveCameraPreset::onPresetsListChange() +{ + LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_HIDE); +} + +void LLFloaterSaveCameraPreset::onBtnCancel() +{ + closeFloater(); +} + +void LLFloaterSaveCameraPreset::onSwitchSaveReplace() +{ + bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; + std::string label = is_saving_new ? getString("btn_label_save") : getString("btn_label_replace"); + mSaveButton->setLabel(label); + mNameEditor->setEnabled(is_saving_new); + mPresetCombo->setEnabled(!is_saving_new); + if (is_saving_new) + { + onPresetNameEdited(); + } + else + { + mSaveButton->setEnabled(true); + } +} diff --git a/indra/newview/llfloatersavecamerapreset.h b/indra/newview/llfloatersavecamerapreset.h new file mode 100644 index 0000000000..282f213438 --- /dev/null +++ b/indra/newview/llfloatersavecamerapreset.h @@ -0,0 +1,60 @@ +/** + * @file llfloatersavecamerapreset.h + * @brief Floater to save a camera preset + + * + * $LicenseInfo:firstyear=2020&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2020, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERSAVECAMERAPRESET_H +#define LL_LLFLOATERSAVECAMERAPRESET_H + +#include "llmodaldialog.h" + +class LLComboBox; +class LLRadioGroup; +class LLLineEditor; + +class LLFloaterSaveCameraPreset : public LLModalDialog +{ + +public: + LLFloaterSaveCameraPreset(const LLSD &key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onBtnSave(); + void onBtnCancel(); + void onSwitchSaveReplace(); + +private: + LLRadioGroup* mSaveRadioGroup; + LLLineEditor* mNameEditor; + LLComboBox* mPresetCombo; + LLButton* mSaveButton; + + void onPresetsListChange(); + void onPresetNameEdited(); +}; + +#endif // LL_LLFLOATERSAVECAMERAPRESET_H diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp index 3142991704..5f3cf9d95b 100644 --- a/indra/newview/llfloatersaveprefpreset.cpp +++ b/indra/newview/llfloatersaveprefpreset.cpp @@ -1,6 +1,6 @@ /** * @file llfloatersaveprefpreset.cpp - * @brief Floater to save a graphics / camera preset + * @brief Floater to save a graphics preset * * $LicenseInfo:firstyear=2014&license=viewerlgpl$ * Second Life Viewer Source Code @@ -32,14 +32,12 @@ #include "llcombobox.h" #include "llfloaterpreference.h" #include "llfloaterreg.h" -#include "lllineeditor.h" #include "llnotificationsutil.h" #include "llpresetsmanager.h" -#include "llradiogroup.h" #include "lltrans.h" LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key) - : LLModalDialog(key) + : LLFloater(key) { } @@ -52,93 +50,51 @@ BOOL LLFloaterSavePrefPreset::postBuild() preferences->addDependentFloater(this); } - mPresetCombo = getChild("preset_combo"); + getChild("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - mNameEditor = getChild("preset_txt_editor"); - mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL); - - mSaveButton = getChild("save"); - mSaveButton->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - - mSaveRadioGroup = getChild("radio_save_preset"); - mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onSwitchSaveReplace, this)); - getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this)); LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this)); + + mSaveButton = getChild("save"); + mPresetCombo = getChild("preset_combo"); return TRUE; } void LLFloaterSavePrefPreset::onPresetNameEdited() { - if (mSaveRadioGroup->getSelectedIndex() == 0) - { - // Disable saving a preset having empty name. - std::string name = mNameEditor->getValue(); - mSaveButton->setEnabled(!name.empty()); - } + // Disable saving a preset having empty name. + std::string name = mPresetCombo->getSimple(); + + mSaveButton->setEnabled(!name.empty()); } void LLFloaterSavePrefPreset::onOpen(const LLSD& key) { - LLModalDialog::onOpen(key); - S32 index = 0; - if (key.has("subdirectory")) - { - mSubdirectory = key["subdirectory"].asString(); - if (key.has("index")) - { - index = key["index"].asInteger(); - } - } - else - { - mSubdirectory = key.asString(); - } - - std::string floater_title = getString(std::string("title_") + mSubdirectory); - - setTitle(floater_title); + mSubdirectory = key.asString(); EDefaultOptions option = DEFAULT_HIDE; LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); - mSaveRadioGroup->setSelectedIndex(index); onPresetNameEdited(); - onSwitchSaveReplace(); } void LLFloaterSavePrefPreset::onBtnSave() { - bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; - std::string name = is_saving_new ? mNameEditor->getText() : mPresetCombo->getSimple(); + std::string name = mPresetCombo->getSimple(); if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT)) { LLNotificationsUtil::add("DefaultPresetNotSaved"); } - else + else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) { - if (is_saving_new) - { - std::list preset_names; - std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(mSubdirectory); - LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE); - if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end()) - { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetAlreadyExists", args); - return; - } - } - if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) - { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetNotSaved", args); - } + LLSD args; + args["NAME"] = name; + LLNotificationsUtil::add("PresetNotSaved", args); } closeFloater(); @@ -154,20 +110,3 @@ void LLFloaterSavePrefPreset::onBtnCancel() { closeFloater(); } - -void LLFloaterSavePrefPreset::onSwitchSaveReplace() -{ - bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; - std::string label = is_saving_new ? getString("btn_label_save") : getString("btn_label_replace"); - mSaveButton->setLabel(label); - mNameEditor->setEnabled(is_saving_new); - mPresetCombo->setEnabled(!is_saving_new); - if (is_saving_new) - { - onPresetNameEdited(); - } - else - { - mSaveButton->setEnabled(true); - } -} diff --git a/indra/newview/llfloatersaveprefpreset.h b/indra/newview/llfloatersaveprefpreset.h index c61379e5ad..ae58180e7f 100644 --- a/indra/newview/llfloatersaveprefpreset.h +++ b/indra/newview/llfloatersaveprefpreset.h @@ -1,6 +1,6 @@ /** * @file llfloatersaveprefpreset.h - * @brief Floater to save a graphics / camera preset + * @brief Floater to save a graphics preset * * $LicenseInfo:firstyear=2014&license=viewerlgpl$ @@ -28,13 +28,11 @@ #ifndef LL_LLFLOATERSAVEPREFPRESET_H #define LL_LLFLOATERSAVEPREFPRESET_H -#include "llmodaldialog.h" +#include "llfloater.h" class LLComboBox; -class LLRadioGroup; -class LLLineEditor; -class LLFloaterSavePrefPreset : public LLModalDialog +class LLFloaterSavePrefPreset : public LLFloater { public: @@ -45,11 +43,9 @@ public: void onBtnSave(); void onBtnCancel(); - void onSwitchSaveReplace(); private: - LLRadioGroup* mSaveRadioGroup; - LLLineEditor* mNameEditor; + LLComboBox* mPresetCombo; LLButton* mSaveButton; diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 5077dbd3b2..10bdb73056 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -257,7 +257,6 @@ void LLPresetsManager::getControlNames(std::vector& names) ("AppearanceCameraMovement") // From llagentcamera.cpp ("CameraOffsetBuild") - //("CameraOffsetScale") // Duplicate ("TrackFocusObject") ("CameraOffsetRearView") ("FocusOffsetRearView") @@ -325,6 +324,9 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n name_list.clear(); getControlNames(name_list); name_list.push_back("PresetCameraActive"); + + gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction()); + name_list.push_back("CameraZoomFraction"); } else { @@ -487,7 +489,7 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, else { combo->setLabel(LLTrans::getString("preset_combo_label")); - combo->setEnabled(FALSE); + combo->setEnabled(PRESETS_CAMERA != subdirectory); sts = false; } } diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index b6ad928ce7..cf5228dd66 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -113,6 +113,7 @@ #include "llfloaterregioninfo.h" #include "llfloaterregionrestarting.h" #include "llfloaterreporter.h" +#include "llfloatersavecamerapreset.h" #include "llfloatersaveprefpreset.h" #include "llfloatersceneloadstats.h" #include "llfloaterscriptdebug.h" @@ -387,6 +388,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("save_camera_preset", "floater_save_camera_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_save_camera_preset.xml b/indra/newview/skins/default/xui/en/floater_save_camera_preset.xml new file mode 100644 index 0000000000..54fdb6d167 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_save_camera_preset.xml @@ -0,0 +1,70 @@ + + + + Save + Replace + + + + + +