From 1e3ee272ae811b862a529b6f3bbebb50a0c22580 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Aug 2018 15:37:10 -0700 Subject: Add an apparent time of day. More OSX complaints. --- indra/newview/llenvironment.cpp | 3 -- indra/newview/llpanelenvironment.cpp | 57 ++++++++++++++++++++-- indra/newview/llpanelenvironment.h | 6 +++ indra/newview/llsettingspicker.h | 4 +- .../default/xui/en/panel_region_environment.xml | 25 +++++++++- 5 files changed, 84 insertions(+), 11 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 60e5b81f15..84e915a95d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -192,9 +192,6 @@ namespace LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); -// pstartsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(0.0, 1.0, 0.0)); -// pendsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(1.0, 0.0, 0.0)); - setIgnoreTimeDeltaThreshold(true); // for the next span ignore the time delta threshold. reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); } diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 907118aa44..1f29e4c054 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -44,6 +44,7 @@ #include "llsettingsvo.h" #include "llappviewer.h" +#include "llcallbacklist.h" //========================================================================= namespace @@ -64,6 +65,7 @@ const std::string LLPanelEnvironmentInfo::SLD_DAYOFFSET("sld_day_offset"); const std::string LLPanelEnvironmentInfo::CHK_ALLOWOVERRIDE("chk_allow_override"); const std::string LLPanelEnvironmentInfo::BTN_APPLY("btn_apply"); const std::string LLPanelEnvironmentInfo::BTN_CANCEL("btn_cancel"); +const std::string LLPanelEnvironmentInfo::LBL_TIMEOFDAY("lbl_apparent_time"); const std::string LLPanelEnvironmentInfo::STR_LABEL_USEDEFAULT("str_label_use_default"); const std::string LLPanelEnvironmentInfo::STR_LABEL_USEREGION("str_label_use_region"); @@ -111,10 +113,11 @@ void LLPanelEnvironmentInfo::onOpen(const LLSD& key) // virtual void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) { - // If hiding (user switched to another tab or closed the floater), - // display user's preferred environment. - // switching back and forth between agent's environment and the one being edited. - // + if (new_visibility) + gIdleCallbacks.addFunction(onIdlePlay, this); + else + gIdleCallbacks.deleteFunction(onIdlePlay, this); + } void LLPanelEnvironmentInfo::refresh() @@ -156,6 +159,8 @@ void LLPanelEnvironmentInfo::refresh() getChild(SLD_DAYLENGTH)->setValue(daylength.value()); getChild(SLD_DAYOFFSET)->setValue(dayoffset.value()); + udpateApparentTimeOfDay(); + setControlsEnabled(canEdit()); } @@ -286,6 +291,8 @@ void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) mCurrentEnvironment->mDayLength = daylength; setDirtyFlag(DIRTY_FLAG_DAYLENGTH); + + udpateApparentTimeOfDay(); } void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) @@ -297,6 +304,8 @@ void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) mCurrentEnvironment->mDayOffset = dayoffset; setDirtyFlag(DIRTY_FLAG_DAYOFFSET); + + udpateApparentTimeOfDay(); } void LLPanelEnvironmentInfo::onBtnApply() @@ -365,6 +374,46 @@ void LLPanelEnvironmentInfo::doApply() } } + +void LLPanelEnvironmentInfo::udpateApparentTimeOfDay() +{ + static const F32 SECONDSINDAY(24.0 * 60.0 * 60.0); + + if (!mCurrentEnvironment) + return; + + S32Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mCurrentEnvironment->mDayOffset; + + F32 perc = (F32)(now.value() % mCurrentEnvironment->mDayLength.value()) / (F32)(mCurrentEnvironment->mDayLength.value()); + + S32Seconds secondofday((S32)(perc * SECONDSINDAY)); + S32Hours hourofday(secondofday); + S32Seconds secondofhour(secondofday - hourofday); + S32Minutes minutesofhour(secondofhour); + bool am_pm(hourofday.value() >= 12); + + if (hourofday.value() < 1) + hourofday = S32Hours(12); + if (hourofday.value() > 12) + hourofday -= S32Hours(12); + + std::string lblminute(((minutesofhour.value() < 10) ? "0" : "") + LLSD(minutesofhour.value()).asString()); + + + getChild(LBL_TIMEOFDAY)->setTextArg("[HH]", LLSD(hourofday.value()).asString()); + getChild(LBL_TIMEOFDAY)->setTextArg("[MM]", lblminute); + getChild(LBL_TIMEOFDAY)->setTextArg("[AP]", std::string(am_pm ? "PM" : "AM")); + getChild(LBL_TIMEOFDAY)->setTextArg("[PRC]", LLSD((S32)(100 * perc)).asString()); + +} + +void LLPanelEnvironmentInfo::onIdlePlay(void *data) +{ + ((LLPanelEnvironmentInfo *)data)->udpateApparentTimeOfDay(); +} + void LLPanelEnvironmentInfo::onPickerCommited(LLUUID asset_id) { LLSettingsVOBase::getSettingsAsset(asset_id, [this](LLUUID, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index 2fcfb725a1..44e3c11a82 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -75,6 +75,8 @@ protected: static const std::string CHK_ALLOWOVERRIDE; static const std::string BTN_APPLY; static const std::string BTN_CANCEL; + static const std::string LBL_TIMEOFDAY; + static const std::string STR_LABEL_USEDEFAULT; static const std::string STR_LABEL_USEREGION; @@ -104,6 +106,8 @@ protected: virtual void doApply(); + void udpateApparentTimeOfDay(); + void onPickerCommited(LLUUID asset_id); void onEditCommited(LLSettingsDay::ptr_t newday); void onPickerAssetDownloaded(LLSettingsBase::ptr_t settings); @@ -121,6 +125,8 @@ protected: private: + static void onIdlePlay(void *); + LLHandle mSettingsFloater; LLHandle mEditFloater; S32 mDirtyFlag; diff --git a/indra/newview/llsettingspicker.h b/indra/newview/llsettingspicker.h index c3ccbe22c3..b3637fd59a 100644 --- a/indra/newview/llsettingspicker.h +++ b/indra/newview/llsettingspicker.h @@ -109,8 +109,8 @@ private: F32 mContextConeOpacity; PermissionMask mImmediateFilterPermMask; - PermissionMask mDnDFilterPermMask; - PermissionMask mNonImmediateFilterPermMask; +// PermissionMask mDnDFilterPermMask; +// PermissionMask mNonImmediateFilterPermMask; bool mActive; bool mNoCopySettingsSelected; diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml index c1cfe79ba4..bb10e0c69e 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -119,7 +119,6 @@ + + Apparent Time of Day Would Be: + + + [HH]:[MM][AP] ([PRC]%) + -- cgit v1.3