From 0a67fa3520a899fd898df6bd8a1f939168f528c5 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Thu, 26 Sep 2013 04:34:17 -0400 Subject: [PATCH] Satisfy Issue 1115: Make clock on top status line toggleable Click the clock to change from server time to local~ --- indra/newview/app_settings/settings.xml | 11 ++++++++++ indra/newview/llstatusbar.cpp | 22 ++++++++++++++----- .../default/xui/en-us/panel_status_bar.xml | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 297648a40..240c181b8 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -753,6 +753,17 @@ Value 0 + LiruLocalTime + + Comment + Whether or not to display system time in the top bar instead of server time. + Persist + 1 + Type + Boolean + Value + 0 + LiruMapShowAvCount Comment diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index fcec44e4b..1bfc7ca9e 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -154,6 +154,12 @@ public: static LLDispatchUPCBalance sDispatchUPCBalance; +static void toggle_time_value() +{ + LLControlVariable* control = gSavedSettings.getControl("LiruLocalTime"); + control->set(!control->get()); +} + LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) : LLPanel(name, LLRect(), FALSE), // not mouse opaque mBalance(0), @@ -195,6 +201,7 @@ mIsNavMeshDirty(false) mTextHealth = getChild("HealthText" ); mTextTime = getChild("TimeText" ); + mTextTime->setClickedCallback(boost::bind(toggle_time_value)); if (!mUPCSupported) mTextUPC->setVisible(false); @@ -314,23 +321,28 @@ void LLStatusBar::refresh() mSGBandwidth->setThreshold(1, bwtotal); mSGBandwidth->setThreshold(2, bwtotal); - // *TODO: Localize / translate time + // Singu Note: Use system's time if the user desires, otherwise use server time + static const LLCachedControl show_local_time("LiruLocalTime"); // Get current UTC time, adjusted for the user's clock // being off. - time_t utc_time; - utc_time = time_corrected(); + time_t utc_time = show_local_time ? time(NULL) : time_corrected(); // There's only one internal tm buffer. struct tm* internal_time; // Convert to Pacific, based on server's opinion of whether // it's daylight savings time there. - internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime); + internal_time = show_local_time ? std::localtime(&utc_time) : utc_to_pacific_time(utc_time, gPacificDaylightTime); std::string t; timeStructToFormattedString(internal_time, gSavedSettings.getString("ShortTimeFormat"), t); - if (gPacificDaylightTime) + if (show_local_time) + { + static const std::string local(" " + getString("Local")); + t += local; + } + else if (gPacificDaylightTime) { t += " PDT"; } diff --git a/indra/newview/skins/default/xui/en-us/panel_status_bar.xml b/indra/newview/skins/default/xui/en-us/panel_status_bar.xml index bf1b1c213..f52574b51 100644 --- a/indra/newview/skins/default/xui/en-us/panel_status_bar.xml +++ b/indra/newview/skins/default/xui/en-us/panel_status_bar.xml @@ -137,4 +137,5 @@ Bandwidth + Local