diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2020-01-08 18:14:21 +0200 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2020-01-08 18:14:21 +0200 |
commit | a2f0fd64e947f96305200edbdfd496529cadb90e (patch) | |
tree | 99871bfa58d575b6e66667edad9875570bb0c504 /indra | |
parent | abd5277a7b3dac90e8a555eefe855cfcca1536dc (diff) |
SL-12510 Revert changes and separate 'Save Graphic Preset' floater
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloatercamera.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llfloatersavecamerapreset.cpp | 153 | ||||
-rw-r--r-- | indra/newview/llfloatersavecamerapreset.h | 60 | ||||
-rw-r--r-- | indra/newview/llfloatersaveprefpreset.cpp | 97 | ||||
-rw-r--r-- | indra/newview/llfloatersaveprefpreset.h | 12 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_save_camera_preset.xml | 70 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_save_pref_preset.xml | 72 |
10 files changed, 335 insertions, 138 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 6472b464d8..8016ce496a 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -296,6 +296,7 @@ set(viewer_SOURCE_FILES llfloaterregioninfo.cpp llfloaterreporter.cpp llfloaterregionrestarting.cpp + llfloatersavecamerapreset.cpp llfloatersaveprefpreset.cpp llfloatersceneloadstats.cpp llfloaterscriptdebug.cpp @@ -923,6 +924,7 @@ set(viewer_HEADER_FILES llfloaterregioninfo.h llfloaterreporter.h llfloaterregionrestarting.h + llfloatersavecamerapreset.h llfloatersaveprefpreset.h llfloatersceneloadstats.h llfloaterscriptdebug.h diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index f45033aa20..860005bfbe 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -610,11 +610,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/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp new file mode 100644 index 0000000000..b1c9e561f7 --- /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<LLComboBox>("preset_combo"); + + mNameEditor = getChild<LLLineEditor>("preset_txt_editor"); + mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSaveCameraPreset::onPresetNameEdited, this), NULL); + + mSaveButton = getChild<LLButton>("save"); + mSaveButton->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onBtnSave, this)); + + mSaveRadioGroup = getChild<LLRadioGroup>("radio_save_preset"); + mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onSwitchSaveReplace, this)); + + getChild<LLButton>("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<std::string> 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<LLComboBox>("preset_combo"); - - mNameEditor = getChild<LLLineEditor>("preset_txt_editor"); - mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL); + getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - mSaveButton = getChild<LLButton>("save"); - mSaveButton->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - - mSaveRadioGroup = getChild<LLRadioGroup>("radio_save_preset"); - mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onSwitchSaveReplace, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this)); LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this)); + + mSaveButton = getChild<LLButton>("save"); + mPresetCombo = getChild<LLComboBox>("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<std::string> 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 73978e9dfb..6b83be2b70 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -430,7 +430,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 d897d59217..90682f8f43 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -112,6 +112,7 @@ #include "llfloaterregioninfo.h" #include "llfloaterregionrestarting.h" #include "llfloaterreporter.h" +#include "llfloatersavecamerapreset.h" #include "llfloatersaveprefpreset.h" #include "llfloatersceneloadstats.h" #include "llfloaterscriptdebug.h" @@ -318,6 +319,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>); LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>); LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>); + LLFloaterReg::add("save_camera_preset", "floater_save_camera_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSaveCameraPreset>); LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>); LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>); 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<floater + legacy_header_height="18" + height="185" + help_topic="floater_save_preset" + layout="topleft" + name="save_camera_preset" + save_rect="true" + title="Save Camera Preset" + width="280"> + + <string name="btn_label_save">Save</string> + <string name="btn_label_replace">Replace</string> + <radio_group + height="85" + layout="topleft" + left="20" + top="15" + width="150" + name="radio_save_preset"> + <radio_item + label="Save as a new preset" + name="new_preset" + top="10" + layout="topleft" + height="16" + value="0"/> + <radio_item + label="Replace a preset" + name="replace_preset" + layout="topleft" + top="70" + height="16" + value="1"/> + </radio_group> + <line_editor + commit_on_focus_lost = "true" + follows="top|left" + height="23" + layout="topleft" + left="41" + name="preset_txt_editor" + width="200" + top="45"/> + <button + follows="top|left" + height="25" + label="Save" + layout="topleft" + top="145" + left="25" + name="save" + width="110"/> + <button + follows="bottom|right" + height="25" + label="Cancel" + layout="topleft" + left_pad="20" + name="cancel" + width="110"/> +<!-- *HACK to correctly draw drop-down list over the buttons--> + <combo_box + follows="top|left" + layout="topleft" + left="41" + name="preset_combo" + top_delta="-40" + width="200"/> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml index 3a5838e846..62260274f5 100644 --- a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml @@ -1,72 +1,48 @@ <?xml version="1.0" encoding="UTF-8"?> <floater legacy_header_height="18" - height="185" + height="145" help_topic="floater_save_preset" layout="topleft" name="save_pref_preset" save_rect="true" - title="SAVE PREF PRESET" - width="280"> + title="Save Graphic Preset" + width="300"> - <string name="title_graphic">Save Graphic Preset</string> - <string name="title_camera">Save Camera Preset</string> - <string name="btn_label_save">Save</string> - <string name="btn_label_replace">Replace</string> - <radio_group - height="85" + <text + follows="top|left|right" + height="32" layout="topleft" + word_wrap="true" left="20" - top="15" - width="150" - name="radio_save_preset"> - <radio_item - label="Save as a new preset" - name="new_preset" - top="10" - layout="topleft" - height="16" - value="0"/> - <radio_item - label="Replace a preset" - name="replace_preset" - layout="topleft" - top="70" - height="16" - value="1"/> - </radio_group> - <line_editor - commit_on_focus_lost = "true" + name="Preset" + top="30" + width="200"> + Type a name for the preset or choose an existing preset. + </text> + <combo_box follows="top|left" - height="23" layout="topleft" - left="41" - name="preset_txt_editor" - width="200" - top="45"/> + left="20" + name="preset_combo" + top_delta="35" + allow_text_entry="true" + width="200"/> <button follows="top|left" - height="25" + height="23" label="Save" layout="topleft" - top="145" - left="25" + top_delta="40" + left="20" name="save" - width="110"/> + width="70"/> <button follows="bottom|right" - height="25" + height="23" label="Cancel" layout="topleft" left_pad="20" name="cancel" - width="110"/> -<!-- *HACK to correctly draw drop-down list over the buttons--> - <combo_box - follows="top|left" - layout="topleft" - left="41" - name="preset_combo" - top_delta="-40" - width="200"/> + width="70"/> </floater> |