Restore function of day cycle editor
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/**
|
/**
|
||||||
* @file llfloaterdaycycle.cpp
|
* @file llfloaterdaycycle.cpp
|
||||||
* @brief LLFloaterDayCycle class definition
|
* @brief LLFloaterDayCycle class definition
|
||||||
*
|
*
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "llsliderctrl.h"
|
#include "llsliderctrl.h"
|
||||||
#include "llmultislider.h"
|
#include "llmultislider.h"
|
||||||
#include "llmultisliderctrl.h"
|
#include "llmultisliderctrl.h"
|
||||||
|
#include "llnotificationsutil.h"
|
||||||
#include "llspinctrl.h"
|
#include "llspinctrl.h"
|
||||||
#include "llcheckboxctrl.h"
|
#include "llcheckboxctrl.h"
|
||||||
#include "lluictrlfactory.h"
|
#include "lluictrlfactory.h"
|
||||||
@@ -53,6 +54,7 @@
|
|||||||
#include "llviewercontrol.h"
|
#include "llviewercontrol.h"
|
||||||
#include "llviewerwindow.h"
|
#include "llviewerwindow.h"
|
||||||
|
|
||||||
|
#include "lldaycyclemanager.h"
|
||||||
#include "llwlparamset.h"
|
#include "llwlparamset.h"
|
||||||
#include "llwlparammanager.h"
|
#include "llwlparammanager.h"
|
||||||
#include "llpostprocess.h"
|
#include "llpostprocess.h"
|
||||||
@@ -89,6 +91,26 @@ LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater(std::string("Day Cycle Floate
|
|||||||
|
|
||||||
sldr->addSlider();
|
sldr->addSlider();
|
||||||
|
|
||||||
|
// add the combo boxes
|
||||||
|
LLComboBox* comboBox = getChild<LLComboBox>("DayCyclePresetsCombo");
|
||||||
|
|
||||||
|
if(comboBox != NULL) {
|
||||||
|
|
||||||
|
LLDayCycleManager::preset_name_list_t day_presets;
|
||||||
|
LLDayCycleManager::getInstance()->getPresetNames(day_presets);
|
||||||
|
LLDayCycleManager::preset_name_list_t::const_iterator it;
|
||||||
|
for(it = day_presets.begin(); it != day_presets.end(); ++it)
|
||||||
|
{
|
||||||
|
comboBox->add(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
// entry for when we're in estate time
|
||||||
|
comboBox->add(LLStringUtil::null);
|
||||||
|
|
||||||
|
// set defaults on combo boxes
|
||||||
|
//comboBox->selectByValue(LLSD("Default"));
|
||||||
|
}
|
||||||
|
|
||||||
// load it up
|
// load it up
|
||||||
initCallbacks();
|
initCallbacks();
|
||||||
}
|
}
|
||||||
@@ -128,8 +150,15 @@ void LLFloaterDayCycle::initCallbacks(void)
|
|||||||
childSetAction("WLAnimSky", onRunAnimSky, NULL);
|
childSetAction("WLAnimSky", onRunAnimSky, NULL);
|
||||||
childSetAction("WLStopAnimSky", onStopAnimSky, NULL);
|
childSetAction("WLStopAnimSky", onStopAnimSky, NULL);
|
||||||
|
|
||||||
childSetAction("WLLoadDayCycle", onLoadDayCycle, NULL);
|
LLComboBox* comboBox = getChild<LLComboBox>("DayCyclePresetsCombo");
|
||||||
childSetAction("WLSaveDayCycle", onSaveDayCycle, NULL);
|
|
||||||
|
//childSetAction("WLLoadPreset", onLoadPreset, comboBox);
|
||||||
|
childSetAction("DayCycleNewPreset", onNewPreset, comboBox);
|
||||||
|
childSetAction("DayCycleSavePreset", onSavePreset, comboBox);
|
||||||
|
childSetAction("DayCycleDeletePreset", onDeletePreset, comboBox);
|
||||||
|
|
||||||
|
comboBox->setCommitCallback(onChangePresetName);
|
||||||
|
|
||||||
|
|
||||||
childSetAction("WLAddKey", onAddKey, NULL);
|
childSetAction("WLAddKey", onAddKey, NULL);
|
||||||
childSetAction("WLDeleteKey", onDeleteKey, NULL);
|
childSetAction("WLDeleteKey", onDeleteKey, NULL);
|
||||||
@@ -269,10 +298,217 @@ void LLFloaterDayCycle::onClose(bool app_quitting)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LLFloaterDayCycle::onNewPreset(void* userData)
|
||||||
|
{
|
||||||
|
LLNotificationsUtil::add("NewDaycyclePreset", LLSD(), LLSD(), newPromptCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLFloaterDayCycle::onSavePreset(void* userData)
|
||||||
|
{
|
||||||
|
// get the name
|
||||||
|
LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>(
|
||||||
|
"DayCyclePresetsCombo");
|
||||||
|
|
||||||
|
std::string name = comboBox->getSelectedItemLabel();
|
||||||
|
|
||||||
|
// don't save the empty name
|
||||||
|
if(name == "")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check to see if it's a default and shouldn't be overwritten
|
||||||
|
|
||||||
|
if(LLDayCycleManager::getInstance()->isSystemPreset(name))
|
||||||
|
{
|
||||||
|
LLNotificationsUtil::add("WLNoEditDefault");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLWLParamManager::getInstance()->mCurParams.mName = name;
|
||||||
|
|
||||||
|
LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LLFloaterDayCycle::saveAlertCallback(const LLSD& notification, const LLSD& response)
|
||||||
|
{
|
||||||
|
S32 option = LLNotification::getSelectedOption(notification, response);
|
||||||
|
// if they choose save, do it. Otherwise, don't do anything
|
||||||
|
if(option == 0)
|
||||||
|
{
|
||||||
|
LLComboBox* combo_box = sDayCycle->getChild<LLComboBox>("DayCyclePresetsCombo");
|
||||||
|
// comment this back in to save to file
|
||||||
|
LLWLParamManager::getInstance()->mDay.saveDayCycle(combo_box->getSelectedValue().asString());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLFloaterDayCycle::onDeletePreset(void* userData)
|
||||||
|
{
|
||||||
|
LLComboBox* combo_box = sDayCycle->getChild<LLComboBox>(
|
||||||
|
"DayCyclePresetsCombo");
|
||||||
|
|
||||||
|
if(combo_box->getSelectedValue().asString() == "")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSD args;
|
||||||
|
args["SKY"] = combo_box->getSelectedValue().asString();
|
||||||
|
LLNotificationsUtil::add("WLDeletePresetAlert", args, LLSD(),
|
||||||
|
boost::bind(&LLFloaterDayCycle::deleteAlertCallback, sDayCycle, _1, _2));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LLFloaterDayCycle::deleteAlertCallback(const LLSD& notification, const LLSD& response)
|
||||||
|
{
|
||||||
|
S32 option = LLNotification::getSelectedOption(notification, response);
|
||||||
|
|
||||||
|
// if they choose delete, do it. Otherwise, don't do anything
|
||||||
|
if(option == 0)
|
||||||
|
{
|
||||||
|
LLComboBox* combo_box = getChild<LLComboBox>(
|
||||||
|
"DayCyclePresetsCombo");
|
||||||
|
LLFloaterDayCycle* day_cycle = NULL;
|
||||||
|
LLComboBox* key_combo = NULL;
|
||||||
|
LLMultiSliderCtrl* mult_sldr = NULL;
|
||||||
|
|
||||||
|
if(LLFloaterDayCycle::isOpen())
|
||||||
|
{
|
||||||
|
day_cycle = LLFloaterDayCycle::instance();
|
||||||
|
key_combo = day_cycle->getChild<LLComboBox>(
|
||||||
|
"WLKeyPresets");
|
||||||
|
mult_sldr = day_cycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string name(combo_box->getSelectedValue().asString());
|
||||||
|
|
||||||
|
// check to see if it's a default and shouldn't be deleted
|
||||||
|
|
||||||
|
if(LLDayCycleManager::getInstance()->isSystemPreset(name))
|
||||||
|
{
|
||||||
|
LLNotificationsUtil::add("WLNoEditDefault");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLDayCycleManager::getInstance()->deletePreset(name);
|
||||||
|
|
||||||
|
// remove and choose another
|
||||||
|
S32 new_index = combo_box->getCurrentIndex();
|
||||||
|
|
||||||
|
combo_box->remove(name);
|
||||||
|
if(key_combo != NULL)
|
||||||
|
{
|
||||||
|
key_combo->remove(name);
|
||||||
|
|
||||||
|
// remove from slider, as well
|
||||||
|
day_cycle->deletePreset(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// pick the previously selected index after delete
|
||||||
|
if(new_index > 0)
|
||||||
|
{
|
||||||
|
new_index--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(combo_box->getItemCount() > 0)
|
||||||
|
{
|
||||||
|
combo_box->setCurrentByIndex(new_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LLFloaterDayCycle::newPromptCallback(const LLSD& notification, const LLSD& response)
|
||||||
|
{
|
||||||
|
std::string text = response["message"].asString();
|
||||||
|
S32 option = LLNotification::getSelectedOption(notification, response);
|
||||||
|
|
||||||
|
if(text == "")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(option == 0) {
|
||||||
|
LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>("DayCyclePresetsCombo");
|
||||||
|
|
||||||
|
LLFloaterDayCycle* sDayCycle = NULL;
|
||||||
|
LLComboBox* keyCombo = NULL;
|
||||||
|
if(LLFloaterDayCycle::isOpen())
|
||||||
|
{
|
||||||
|
sDayCycle = LLFloaterDayCycle::instance();
|
||||||
|
keyCombo = sDayCycle->getChild<LLComboBox>("WLKeyPresets");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// add the current parameters to the list
|
||||||
|
// see if it's there first
|
||||||
|
// if not there, add a new one
|
||||||
|
if(LLDayCycleManager::getInstance()->findPreset(text).empty())
|
||||||
|
{
|
||||||
|
//AscentDayCycleManager::instance()->addParamSet(text,
|
||||||
|
// AscentDayCycleManager::instance()->mCurParams);
|
||||||
|
|
||||||
|
LLDayCycleManager::getInstance()->savePreset(text,
|
||||||
|
LLWLParamManager::getInstance()->mDay.asLLSD());
|
||||||
|
|
||||||
|
comboBox->add(text);
|
||||||
|
comboBox->sortByName();
|
||||||
|
|
||||||
|
// add a blank to the bottom
|
||||||
|
comboBox->selectFirstItem();
|
||||||
|
if(comboBox->getSimple() == "")
|
||||||
|
{
|
||||||
|
comboBox->remove(0);
|
||||||
|
}
|
||||||
|
comboBox->add(LLStringUtil::null);
|
||||||
|
|
||||||
|
comboBox->setSelectedByValue(text, true);
|
||||||
|
if(LLFloaterDayCycle::isOpen())
|
||||||
|
{
|
||||||
|
keyCombo->add(text);
|
||||||
|
keyCombo->sortByName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // otherwise, send a message to the user
|
||||||
|
{
|
||||||
|
LLNotificationsUtil::add("ExistsSkyPresetAlert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LLFloaterDayCycle::onChangePresetName(LLUICtrl* ctrl, void * userData)
|
||||||
|
{
|
||||||
|
LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl);
|
||||||
|
|
||||||
|
if(combo_box->getSimple() == "")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLEnvManagerNew::getInstance()->useDayCycle(combo_box->getSelectedValue().asString(), LLEnvKey::SCOPE_LOCAL);
|
||||||
|
|
||||||
|
gSavedSettings.setString("AscentActiveDayCycle", combo_box->getSelectedValue().asString());
|
||||||
|
// sync it all up
|
||||||
|
syncSliderTrack();
|
||||||
|
syncMenu();
|
||||||
|
|
||||||
|
// set the param manager's track to the new one
|
||||||
|
LLMultiSliderCtrl* tSldr;
|
||||||
|
tSldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLTimeSlider");
|
||||||
|
LLWLParamManager::getInstance()->resetAnimator(tSldr->getCurSliderValue() / sHoursPerDay, false);
|
||||||
|
|
||||||
|
// and draw it
|
||||||
|
LLWLParamManager::getInstance()->mAnimator.update(LLWLParamManager::getInstance()->mCurParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LLFloaterDayCycle::onRunAnimSky(void* userData)
|
void LLFloaterDayCycle::onRunAnimSky(void* userData)
|
||||||
{
|
{
|
||||||
// if no keys, do nothing
|
// if no keys, do nothing
|
||||||
if(sSliderToKey.size() == 0)
|
if(sSliderToKey.size() == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -315,32 +551,6 @@ void LLFloaterDayCycle::onUseLindenTime(void* userData)
|
|||||||
LLEnvManagerNew::instance().setUseDayCycle(LLEnvManagerNew::instance().getDayCycleName());
|
LLEnvManagerNew::instance().setUseDayCycle(LLEnvManagerNew::instance().getDayCycleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLFloaterDayCycle::onLoadDayCycle(void* userData)
|
|
||||||
{
|
|
||||||
LLWLParamManager::getInstance()->mDay.loadDayCycleFromFile("Default.xml");
|
|
||||||
|
|
||||||
// sync it all up
|
|
||||||
syncSliderTrack();
|
|
||||||
syncMenu();
|
|
||||||
|
|
||||||
// set the param manager's track to the new one
|
|
||||||
LLMultiSliderCtrl* tSldr;
|
|
||||||
tSldr = sDayCycle->getChild<LLMultiSliderCtrl>(
|
|
||||||
"WLTimeSlider");
|
|
||||||
LLWLParamManager::getInstance()->resetAnimator(
|
|
||||||
tSldr->getCurSliderValue() / sHoursPerDay, false);
|
|
||||||
|
|
||||||
// and draw it
|
|
||||||
LLWLParamManager::getInstance()->mAnimator.update(
|
|
||||||
LLWLParamManager::getInstance()->mCurParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LLFloaterDayCycle::onSaveDayCycle(void* userData)
|
|
||||||
{
|
|
||||||
LLWLParamManager::getInstance()->mDay.saveDayCycle("Default.xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl, void* userData)
|
void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl, void* userData)
|
||||||
{
|
{
|
||||||
LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>(
|
LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>(
|
||||||
|
|||||||
@@ -99,11 +99,25 @@ public:
|
|||||||
/// delete a key frame
|
/// delete a key frame
|
||||||
static void onDeleteKey(void* userData);
|
static void onDeleteKey(void* userData);
|
||||||
|
|
||||||
/// button to load day
|
/// when user hits the load preset button
|
||||||
static void onLoadDayCycle(void* userData);
|
static void onNewPreset(void* userData);
|
||||||
|
|
||||||
/// button to save day
|
/// when user hits the save preset button
|
||||||
static void onSaveDayCycle(void* userData);
|
static void onSavePreset(void* userData);
|
||||||
|
|
||||||
|
/// prompts a user when overwriting a preset
|
||||||
|
static bool saveAlertCallback(const LLSD& notification, const LLSD& response);
|
||||||
|
|
||||||
|
/// when user hits the save preset button
|
||||||
|
static void onDeletePreset(void* userData);
|
||||||
|
|
||||||
|
/// prompts a user when overwriting a preset
|
||||||
|
bool deleteAlertCallback(const LLSD& notification, const LLSD& response);
|
||||||
|
|
||||||
|
static bool newPromptCallback(const LLSD& notification, const LLSD& response);
|
||||||
|
|
||||||
|
/// what to do when you change the preset name
|
||||||
|
static void onChangePresetName(LLUICtrl* ctrl, void* userData);
|
||||||
|
|
||||||
/// toggle for Linden time
|
/// toggle for Linden time
|
||||||
static void onUseLindenTime(void* userData);
|
static void onUseLindenTime(void* userData);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<button bottom_delta="0" height="18" label="<" left="158" image_overlay="arrow_left.tga" name="WWprev" width="18"/>
|
<button bottom_delta="0" height="18" label="<" left="158" image_overlay="arrow_left.tga" name="WWprev" width="18"/>
|
||||||
<button bottom_delta="0" height="18" label=">" left_delta="18" image_overlay="arrow_right.tga" name="WWnext" width="18"/>
|
<button bottom_delta="0" height="18" label=">" left_delta="18" image_overlay="arrow_right.tga" name="WWnext" width="18"/>
|
||||||
<check_box left="5" label="Region Environment" control_name="UseEnvironmentFromRegion" height="16" name="use_estate_wl" tool_tip="Use the region/parcel's windlight settings when available."/>
|
<check_box left="5" label="Region Environment" control_name="UseEnvironmentFromRegion" height="16" name="use_estate_wl" tool_tip="Use the region/parcel's windlight settings when available."/>
|
||||||
<check_box bottom_delta="0" left_delta="125" label="Always?" control_name="UseEnvironmentFromRegionAlways" height="16" name="Always" tool_tip="Always use region/parcel settings when they exist, automatically."/>
|
<!--check_box bottom_delta="0" left_delta="125" label="Always?" control_name="UseEnvironmentFromRegionAlways" height="16" name="Always" tool_tip="Always use region/parcel settings when they exist, automatically."/-->
|
||||||
<icon bottom_delta="-18" height="14" image_name="icon_day_cycle.tga" left="10" width="150"/>
|
<icon bottom_delta="-18" height="14" image_name="icon_day_cycle.tga" left="10" width="150"/>
|
||||||
<slider bottom_delta="-8" control_name="EnvTimeSlider" left="5" height="10" increment="0.00000001" label="" max_val="1" min_val="0" name="EnvTimeSlider" show_text="false" width="160"/>
|
<slider bottom_delta="-8" control_name="EnvTimeSlider" left="5" height="10" increment="0.00000001" label="" max_val="1" min_val="0" name="EnvTimeSlider" show_text="false" width="160"/>
|
||||||
<button bottom="1" height="22" label="" left="172" name="expand" scale_image="true" toggle="true" tool_tip="Hide the Settings Panel" width="22"/>
|
<button bottom="1" height="22" label="" left="172" name="expand" scale_image="true" toggle="true" tool_tip="Hide the Settings Panel" width="22"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user