Preliminary work for Day Cycle selecting.

Signed-off-by: Beeks <HgDelirium@gmail.com>
This commit is contained in:
Beeks
2010-10-06 14:44:29 -04:00
parent d08bf75d14
commit 015bfe5bd7
12 changed files with 459 additions and 65 deletions

View File

@@ -64,6 +64,7 @@ include_directories(
)
set(viewer_SOURCE_FILES
ascentdaycyclemanager.cpp
ascentfloatercontactgroups.cpp
ascentprefssys.cpp
ascentprefsvan.cpp
@@ -513,6 +514,7 @@ endif (LINUX)
set(viewer_HEADER_FILES
CMakeLists.txt
ViewerInstall.cmake
ascentdaycyclemanager.h
ascentfloatercontactgroups.h
ascentprefssys.h
ascentprefsvan.h

View File

@@ -867,6 +867,17 @@
<key>Value</key>
<string>Custom</string>
</map>
<key>AscentActiveDayCycle</key>
<map>
<key>Comment</key>
<string>Day cycle currently in use</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>Default</string>
</map>
<key>AscentAutoCloseOOC</key>
<map>
<key>Comment</key>

View File

@@ -1,36 +1,36 @@
<llsd>
<array>
<array>
<real>0</real>
<string>A-12AM</string>
</array>
<array>
<real>0.125</real>
<string>A-3AM</string>
</array>
<array>
<real>0.25</real>
<string>A-6AM</string>
</array>
<array>
<real>0.375</real>
<string>A-9AM</string>
</array>
<array>
<real>0.5</real>
<string>A-12PM</string>
</array>
<array>
<real>0.625</real>
<string>A-3PM</string>
</array>
<array>
<real>0.75</real>
<string>A-6PM</string>
</array>
<array>
<real>0.875</real>
<string>A-9PM</string>
</array>
</array>
</llsd>
<llsd>
<array>
<array>
<real>0</real>
<string>A-12AM</string>
</array>
<array>
<real>0.125</real>
<string>A-3AM</string>
</array>
<array>
<real>0.25</real>
<string>A-6AM</string>
</array>
<array>
<real>0.375</real>
<string>A-9AM</string>
</array>
<array>
<real>0.5</real>
<string>A-12PM</string>
</array>
<array>
<real>0.625</real>
<string>A-3PM</string>
</array>
<array>
<real>0.75</real>
<string>A-6PM</string>
</array>
<array>
<real>0.875</real>
<string>A-9PM</string>
</array>
</array>
</llsd>

View File

@@ -37,6 +37,7 @@
#include "pipeline.h"
#include "llsky.h"
#include "llboost.h"
#include "llsliderctrl.h"
#include "llmultislider.h"
#include "llmultisliderctrl.h"
@@ -54,12 +55,16 @@
#include "llviewerwindow.h"
#include "llwlparamset.h"
#include "llwldaycycle.h"
#include "llwlparammanager.h"
#include "ascentdaycyclemanager.h" //Ascent Addition
#include "llpostprocess.h"
#include "llfloaterwindlight.h"
LLFloaterDayCycle* LLFloaterDayCycle::sDayCycle = NULL;
std::set<std::string> LLFloaterDayCycle::sDefaultPresets;
std::map<std::string, LLWLSkyKey> LLFloaterDayCycle::sSliderToKey;
const F32 LLFloaterDayCycle::sHoursPerDay = 24.0f;
@@ -88,6 +93,37 @@ LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater(std::string("Day Cycle Floate
sldr->addSlider();
// add the combo boxes
LLComboBox* comboBox = getChild<LLComboBox>("DayCyclePresetsCombo");
if(comboBox != NULL) {
std::map<std::string, LLWLDayCycle>::iterator mIt =
AscentDayCycleManager::instance()->mParamList.begin();
for(; mIt != AscentDayCycleManager::instance()->mParamList.end(); mIt++)
{
comboBox->add(mIt->first);
}
// entry for when we're in estate time
comboBox->add(LLStringUtil::null);
// set defaults on combo boxes
comboBox->selectByValue(LLSD("Default"));
}
// add the list of presets
std::string def_days = getString("DaycycleDefaultNames");
// no editing or deleting of the blank string
sDefaultPresets.insert("");
boost_tokenizer tokens(def_days, boost::char_separator<char>(":"));
for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter)
{
std::string tok(*token_iter);
//sDefaultPresets.insert(tok);
}
// load it up
initCallbacks();
}
@@ -130,6 +166,15 @@ void LLFloaterDayCycle::initCallbacks(void)
childSetAction("WLLoadDayCycle", onLoadDayCycle, NULL);
childSetAction("WLSaveDayCycle", onSaveDayCycle, NULL);
LLComboBox* comboBox = getChild<LLComboBox>("DayCyclePresetsCombo");
//childSetAction("WLLoadPreset", onLoadPreset, comboBox);
childSetAction("DayCycleNewPreset", onNewPreset, comboBox);
childSetAction("DayCycleSavePreset", onSavePreset, comboBox);
childSetAction("DayCycleDeletePreset", onDeletePreset, comboBox);
comboBox->setCommitCallback(onChangePresetName);
childSetAction("WLAddKey", onAddKey, NULL);
childSetAction("WLDeleteKey", onDeleteKey, NULL);
}
@@ -268,6 +313,216 @@ void LLFloaterDayCycle::onClose(bool app_quitting)
}
}
void LLFloaterDayCycle::onNewPreset(void* userData)
{
LLNotifications::instance().add("NewDaycyclePreset", LLSD(), LLSD(), newPromptCallback);
}
void LLFloaterDayCycle::onSavePreset(void* userData)
{
// get the name
LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>(
"DayCyclePresetsCombo");
// don't save the empty name
if(comboBox->getSelectedItemLabel() == "")
{
return;
}
// check to see if it's a default and shouldn't be overwritten
std::set<std::string>::iterator sIt = sDefaultPresets.find(
comboBox->getSelectedItemLabel());
if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets"))
{
LLNotifications::instance().add("WLNoEditDefault");
return;
}
LLWLParamManager::instance()->mCurParams.mName =
comboBox->getSelectedItemLabel();
LLNotifications::instance().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::instance()->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();
LLNotifications::instance().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
std::set<std::string>::iterator sIt = sDefaultPresets.find(name);
if(sIt != sDefaultPresets.end())
{
LLNotifications::instance().add("WLNoEditDefault");
return false;
}
AscentDayCycleManager::instance()->removeParamSet(name, true);
// 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
std::map<std::string, LLWLDayCycle>::iterator mIt =
AscentDayCycleManager::instance()->mParamList.find(text);
// if not there, add a new one
if(mIt == AscentDayCycleManager::instance()->mParamList.end())
{
AscentDayCycleManager::instance()->addParamSet(text,
AscentDayCycleManager::instance()->mCurParams);
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();
}
LLWLParamManager::instance()->mDay.saveDayCycle(text);
// otherwise, send a message to the user
}
else
{
LLNotifications::instance().add("ExistsSkyPresetAlert");
}
}
return false;
}
void LLFloaterDayCycle::onChangePresetName(LLUICtrl* ctrl, void * userData)
{
LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl);
if(combo_box->getSimple() == "")
{
return;
}
LLWLParamManager::instance()->mDay.loadDayCycle(combo_box->getSelectedValue().asString());
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::instance()->resetAnimator(
tSldr->getCurSliderValue() / sHoursPerDay, false);
// and draw it
LLWLParamManager::instance()->mAnimator.update(
LLWLParamManager::instance()->mCurParams);
}
void LLFloaterDayCycle::onRunAnimSky(void* userData)
{
// if no keys, do nothing
@@ -307,8 +562,8 @@ void LLFloaterDayCycle::onStopAnimSky(void* userData)
void LLFloaterDayCycle::onUseLindenTime(void* userData)
{
LLFloaterWindLight* wl = LLFloaterWindLight::instance();
LLComboBox* box = wl->getChild<LLComboBox>("WLPresetsCombo");
LLFloaterDayCycle* dc = LLFloaterDayCycle::instance();
LLComboBox* box = dc->getChild<LLComboBox>("DayCyclePresetsCombo");
box->selectByValue("");
LLWLParamManager::instance()->mAnimator.mIsRunning = true;
@@ -317,7 +572,7 @@ void LLFloaterDayCycle::onUseLindenTime(void* userData)
void LLFloaterDayCycle::onLoadDayCycle(void* userData)
{
LLWLParamManager::instance()->mDay.loadDayCycle("Default.xml");
//LLWLParamManager::instance()->mDay.loadDayCycle("Default.xml");
// sync it all up
syncSliderTrack();
@@ -337,7 +592,7 @@ void LLFloaterDayCycle::onLoadDayCycle(void* userData)
void LLFloaterDayCycle::onSaveDayCycle(void* userData)
{
LLWLParamManager::instance()->mDay.saveDayCycle("Default.xml");
//LLWLParamManager::instance()->mDay.saveDayCycle("Default.xml");
}

View File

@@ -99,10 +99,30 @@ public:
/// delete a key frame
static void onDeleteKey(void* userData);
/// button to load day
/// when user hits the load preset button
static void onNewPreset(void* userData);
/// when user hits the save preset button
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);
/// button to load day OLD -HgB
static void onLoadDayCycle(void* userData);
/// button to save day
/// button to save day OLD -HgB
static void onSaveDayCycle(void* userData);
/// toggle for Linden time
@@ -140,6 +160,9 @@ private:
// map of sliders to parameters
static std::map<std::string, LLWLSkyKey> sSliderToKey;
//Presets default
static std::set<std::string> sDefaultPresets;
static const F32 sHoursPerDay;
};

View File

@@ -193,11 +193,13 @@
#include "llsocks5.h"
#include "jcfloaterareasearch.h"
// <edit>
#include "llpanellogin.h"
//#include "llfloateravatars.h"
//#include "llactivation.h"
#include "wlfPanel_AdvSettings.h" //Lower right Windlight and Rendering options
#include "ascentdaycyclemanager.h"
#include "llao.h"
#include "llfloaterblacklist.h"
#include "scriptcounter.h"
@@ -2528,6 +2530,7 @@ bool idle_startup()
// init the shader managers
LLPostProcess::initClass();
LLWLParamManager::initClass();
AscentDayCycleManager::initClass();
LLWaterParamManager::initClass();
// RN: don't initialize VO classes in drone mode, they are too closely tied to rendering

View File

@@ -40,7 +40,9 @@
#include <map>
LLWLDayCycle::LLWLDayCycle() : mDayRate(120)
LLWLDayCycle::LLWLDayCycle() :
mDayRate(120),
mName("Unnamed Cycle")
{
}
@@ -54,22 +56,39 @@ void LLWLDayCycle::loadDayCycle(const std::string & fileName)
// clear the first few things
mTimeMap.clear();
// now load the file
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,
"windlight/days", fileName));
llinfos << "Loading DayCycle settings from " << pathName << llendl;
llifstream day_cycle_xml(pathName);
if (day_cycle_xml.is_open())
// bugfix for SL-46920: preventing filenames that break stuff.
char * curl_str = curl_escape(fileName.c_str(), fileName.size());
std::string escaped_filename(curl_str);
curl_free(curl_str);
curl_str = NULL;
escaped_filename += ".xml";
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", escaped_filename));
llinfos << "Loading Day Cycle preset from " << pathName << llendl;
llifstream day_cycle_xml;
day_cycle_xml.open(pathName.c_str());
// That failed, try loading from the users area instead.
if(!day_cycle_xml)
{
pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", escaped_filename);
llinfos << "Loading User Day Cycle preset from " << pathName << llendl;
day_cycle_xml.open(pathName.c_str());
}
if (day_cycle_xml)
{
// load and parse it
LLSD day_data(LLSD::emptyArray());
LLPointer<LLSDParser> parser = new LLSDXMLParser();
parser->parse(day_cycle_xml, day_data, LLSDSerialize::SIZE_UNLIMITED);
llinfos << "Loading day cycle into timeline..." << llendl;
// add each key
for(S32 i = 0; i < day_data.size(); ++i)
{
llinfos << "Loading value" << i << llendl;
// make sure it's a two array
if(day_data[i].size() != 2)
{
@@ -95,14 +114,39 @@ void LLWLDayCycle::loadDayCycle(const std::string & fileName)
day_cycle_xml.close();
}
else
{
llwarns << "Can't find " << fileName << llendl;
return;
}
}
void LLWLDayCycle::saveDayCycle(const std::string & fileName)
{
LLSD day_data(LLSD::emptyArray());
// bugfix for SL-46920: preventing filenames that break stuff.
char * curl_str = curl_escape(fileName.c_str(), fileName.size());
std::string escaped_filename(curl_str);
curl_free(curl_str);
curl_str = NULL;
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName));
//llinfos << "Saving WindLight settings to " << pathName << llendl;
escaped_filename += ".xml";
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", escaped_filename));
llinfos << "Saving Day Cycle preset from " << pathName << llendl;
llofstream day_cycle_xml;
day_cycle_xml.open(pathName.c_str());
// That failed, try loading from the users area instead.
if(!day_cycle_xml)
{
pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", escaped_filename);
llinfos << "Saving User Day Cycle preset from " << pathName << llendl;
day_cycle_xml.open(pathName.c_str());
}
LLSD day_data(LLSD::emptyArray());
for(std::map<F32, std::string>::const_iterator mIt = mTimeMap.begin();
mIt != mTimeMap.end();
@@ -114,7 +158,6 @@ void LLWLDayCycle::saveDayCycle(const std::string & fileName)
day_data.append(key);
}
llofstream day_cycle_xml(pathName);
LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
formatter->format(day_data, day_cycle_xml, LLSDFormatter::OPTIONS_PRETTY);
day_cycle_xml.close();

View File

@@ -45,6 +45,9 @@ class LLWLDayCycle;
class LLWLDayCycle
{
public:
std::string mName;
public:
// lists what param sets are used when during the day

View File

@@ -553,7 +553,7 @@ LLWLParamManager * LLWLParamManager::instance()
sInstance->loadPresets(LLStringUtil::null);
// load the day
sInstance->mDay.loadDayCycle(std::string("Default.xml"));
sInstance->mDay.loadDayCycle(gSavedSettings.getString("AscentActiveDayCycle"));
// *HACK - sets cloud scrolling to what we want... fix this better in the future
sInstance->getParamSet("Default", sInstance->mCurParams);

View File

@@ -237,14 +237,36 @@
label="Use Estate Time" label_selected="Go to Estate Time"
left_delta="55" mouse_opaque="true" name="WLUseLindenTime"
scale_image="true" width="140" />
<button bottom="-195" enabled="true" font="SansSerif" halign="center" height="20"
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
bottom="-180" drop_shadow_visible="true"
font="SansSerif" h_pad="0" halign="left" height="16"
left="430" mouse_opaque="true" name="KeyFramePresetsText" v_pad="0"
width="110">
Presets:
</text>
<combo_box allow_text_entry="false" bottom_delta="-1" follows="left|top" height="18"
left_delta="80" max_chars="20" mouse_opaque="true" name="DayCyclePresetsCombo"
width="120" />
<button bottom_delta="-40" enabled="true" font="SansSerif" halign="center" height="20"
label="New" label_selected="New" left_delta="-80"
mouse_opaque="true" name="DayCycleNewPreset" scale_image="true" width="60" />
<button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20"
label="Save" label_selected="Save" left_delta="70"
mouse_opaque="true" name="DayCycleSavePreset" scale_image="true" width="60" />
<button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20"
label="Delete" label_selected="Delete" left_delta="70"
mouse_opaque="true" name="DayCycleDeletePreset" scale_image="true" width="60" />
<!--<button bottom="-295" enabled="true" font="SansSerif" halign="center" height="20"
label="Save Test Day" label_selected="Save Test Day"
left="480" mouse_opaque="true" name="WLSaveDayCycle" scale_image="true"
width="150" />
<button bottom="-220" enabled="true" font="SansSerif" halign="center" height="20"
<button bottom="-320" enabled="true" font="SansSerif" halign="center" height="20"
label="Load Test Day" label_selected="Load Test Day"
left="480" mouse_opaque="true" name="WLLoadDayCycle" scale_image="true"
width="150" />
width="150" />-->
</panel>
</tab_container>
<string name="DaycycleDefaultNames">
Default:Happy%20Bivouac
</string>
</floater>

View File

@@ -655,10 +655,14 @@
</menu_item_call>
<menu_item_separator bottom="-113" enabled="true" height="8" label="-----------" left="0"
mouse_opaque="true" name="separator" width="169" />
<menu_item_call bottom="-132" enabled="false" height="19" label="Environment Editor" left="0"
<menu_item_call bottom="-132" enabled="false" height="19" label="Environment Editor" left="0"
mouse_opaque="true" name="Environment Editor" width="169">
<on_click function="World.EnvSettings" userdata="editor" />
</menu_item_call>
<on_click function="World.EnvSettings" userdata="editor" />
</menu_item_call>
<menu_item_call bottom="-151" enabled="false" height="19" label="Day Cycle Editor" left="0"
mouse_opaque="true" name="Day Cycle Editor" width="169">
<on_click function="World.DayCycle" userdata="editor" />
</menu_item_call>
</menu>
</menu>
<menu bottom="-18" create_jump_keys="true" drop_shadow="true" enabled="true"

View File

@@ -4904,10 +4904,10 @@ Controls where and how fast the the small scaled version of the normal map moves
icon="alert.tga"
name="NewSkyPreset"
type="alert">
Give me a name for the new sky.
Give me a name for the new sky.
<form name="form">
<input name="message" type="text">
New Preset
New Preset
</input>
<button
default="true"
@@ -4925,7 +4925,35 @@ New Preset
icon="alertmodal.tga"
name="ExistsSkyPresetAlert"
type="alertmodal">
Preset already exists!
Preset already exists!
</notification>
<notification
icon="alert.tga"
name="NewDaycyclePreset"
type="alert">
Set a name for the new day cycle.
<form name="form">
<input name="message" type="text">
New Day
</input>
<button
default="true"
index="0"
name="OK"
text="OK"/>
<button
index="1"
name="Cancel"
text="Cancel"/>
</form>
</notification>
<notification
icon="alertmodal.tga"
name="ExistsDaycylePresetAlert"
type="alertmodal">
Preset already exists!
</notification>
<notification