Merge viewer-camus

master
Ansariel 2020-01-08 20:16:01 +01:00
commit 2e2bf007b8
15 changed files with 388 additions and 153 deletions

View File

@ -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

View File

@ -63,6 +63,17 @@
<key>Value</key>
<real>1</real>
</map>
<key>CameraZoomFraction</key>
<map>
<key>Comment</key>
<string>Mousewheel driven fraction of zoom</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.9</real>
</map>
<key>EditCameraMovement</key>
<map>
<key>Comment</key>

View File

@ -63,6 +63,17 @@
<key>Value</key>
<real>1</real>
</map>
<key>CameraZoomFraction</key>
<map>
<key>Comment</key>
<string>Mousewheel driven fraction of zoom</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.9</real>
</map>
<key>EditCameraMovement</key>
<map>
<key>Comment</key>

View File

@ -63,6 +63,17 @@
<key>Value</key>
<real>1</real>
</map>
<key>CameraZoomFraction</key>
<map>
<key>Comment</key>
<string>Mousewheel driven fraction of zoom</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.9</real>
</map>
<key>EditCameraMovement</key>
<map>
<key>Comment</key>

View File

@ -3061,6 +3061,17 @@
<key>Value</key>
<real>1.0</real>
</map>
<key>CameraZoomFraction</key>
<map>
<key>Comment</key>
<string>Mousewheel driven fraction of zoom</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.9</real>
</map>
<key>CameraPosOnLogout</key>
<map>
<key>Comment</key>

View File

@ -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()

View File

@ -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()

View File

@ -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);
}
}

View File

@ -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

View File

@ -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");
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));
mNameEditor = getChild<LLLineEditor>("preset_txt_editor");
mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL);
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);
}
}

View File

@ -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;

View File

@ -257,7 +257,6 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
("AppearanceCameraMovement")
// From llagentcamera.cpp
("CameraOffsetBuild")
//("CameraOffsetScale") // <FS:Ansariel> 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;
}
}

View File

@ -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<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>);

View File

@ -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>

View File

@ -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"
name="Preset"
top="30"
width="200">
Type a name for the preset or choose an existing preset.
</text>
<combo_box
follows="top|left"
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"
name="preset_combo"
top_delta="35"
allow_text_entry="true"
width="200"/>
<button
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"
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>