From c5b42b7e783743203d08cc69ac922431cfd58e4d Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 30 Jul 2010 17:08:24 -0700 Subject: Added option in Preferences > General for setting the default time to 12 hour/24 hour/UTC. Side effects: moved crash logger settings to advanced prefs, fixed french date translations, past/future dates and times still need to be correctly formatted --- linden/indra/newview/CMakeLists.txt | 2 + linden/indra/newview/app_settings/settings.xml | 22 + linden/indra/newview/llappviewer.cpp | 22 +- linden/indra/newview/llpanelgeneral.cpp | 10 +- linden/indra/newview/llprefsadvanced.cpp | 8 + linden/indra/newview/llstatusbar.cpp | 127 +-- linden/indra/newview/llstatusbar.h | 9 +- linden/indra/newview/llviewertexteditor.cpp | 14 +- .../skins/default/xui/da/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/da/strings.xml | 9 + .../skins/default/xui/de/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/de/strings.xml | 989 +++++++++++---------- .../xui/en-us/panel_preferences_advanced.xml | 19 + .../xui/en-us/panel_preferences_general.xml | 18 +- .../skins/default/xui/en-us/panel_status_bar.xml | 6 - .../newview/skins/default/xui/en-us/strings.xml | 6 + .../skins/default/xui/es/panel_status_bar.xml | 70 +- .../indra/newview/skins/default/xui/es/strings.xml | 9 + .../skins/default/xui/fr/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/fr/strings.xml | 989 +++++++++++---------- .../skins/default/xui/hu/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/hu/strings.xml | 9 + .../skins/default/xui/it/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/it/strings.xml | 9 + .../skins/default/xui/ja/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/ja/strings.xml | 989 +++++++++++---------- .../skins/default/xui/ko/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/ko/strings.xml | 9 + .../skins/default/xui/pl/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/pl/strings.xml | 9 + .../skins/default/xui/pt/panel_status_bar.xml | 70 +- .../indra/newview/skins/default/xui/pt/strings.xml | 981 ++++++++++---------- .../skins/default/xui/ru/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/ru/strings.xml | 9 + .../skins/default/xui/tr/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/tr/strings.xml | 9 + .../skins/default/xui/uk/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/uk/strings.xml | 9 + .../skins/default/xui/zh/panel_status_bar.xml | 6 - .../indra/newview/skins/default/xui/zh/strings.xml | 9 + linden/indra/newview/viewertime.cpp | 260 ++++++ linden/indra/newview/viewertime.h | 88 ++ 42 files changed, 2605 insertions(+), 2256 deletions(-) create mode 100644 linden/indra/newview/viewertime.cpp create mode 100644 linden/indra/newview/viewertime.h diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 1668609..a5f2cbb 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -472,6 +472,7 @@ set(viewer_SOURCE_FILES rlvmultistringsearch.cpp rlvextensions.cpp rlvfloaterbehaviour.cpp + viewertime.cpp viewerversion.cpp ) @@ -914,6 +915,7 @@ set(viewer_HEADER_FILES rlvmultistringsearch.h rlvextensions.h rlvfloaterbehaviour.h + viewertime.h viewerversion.h ) diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index f4a88c7..a59fac6 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -734,6 +734,17 @@ Value f54a0c32-3cd1-d49a-5b4f-7b792bebc204 + Use24HourTime + + Comment + Display time in the 24 hour format + Persist + 1 + Type + Boolean + Value + 0 + UseKDUIfAvailable Comment @@ -745,6 +756,17 @@ Value 1 + UseUTCTime + + Comment + Display time in UTC (universal time) + Persist + 1 + Type + Boolean + Value + 0 + VerticalIMTabs Comment diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index c03c63d..cba1af1 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -168,7 +168,7 @@ #include "llimview.h" #include "llviewerthrottle.h" #include "llparcel.h" - +#include "viewertime.h" #include "llinventoryview.h" @@ -433,6 +433,9 @@ static void settings_to_globals() LLSlider::setScrollWheelMultiplier( gSavedSettings.getS32("SliderScrollWheelMultiplier") ); LLHUDEffectLookAt::sDebugLookAt = gSavedSettings.getBOOL("PersistShowLookAt"); + + ViewerTime::sUse24HourTime = gSavedSettings.getBOOL("Use24HourTime"); + ViewerTime::sUseUTCTime = gSavedSettings.getBOOL("UseUTCTime"); } static void settings_modify() @@ -1243,6 +1246,15 @@ bool LLAppViewer::cleanup() LLWorldMap::getInstance()->reset(); // release any images LLCalc::cleanUp(); + + delete gHippoGridManager; + gHippoGridManager = NULL; + + delete gHippoLimits; + gHippoLimits = NULL; + + delete gViewerTime; + gViewerTime = NULL; llinfos << "Global stuff deleted" << llendflush; @@ -1457,7 +1469,7 @@ bool LLAppViewer::cleanup() } // Delete workers first - // shotdown all worker threads before deleting them in case of co-dependencies + // shutdown all worker threads before deleting them in case of co-dependencies sTextureCache->shutdown(); sTextureFetch->shutdown(); sImageDecodeThread->shutdown(); @@ -2297,6 +2309,12 @@ bool LLAppViewer::initWindow() LLTrans::parseStrings("strings.xml"); LLUITrans::parseStrings("ui_strings.xml"); + // Start up the viewer's clock -- MC + if (!gViewerTime) + { + gViewerTime = new ViewerTime(); + } + // Show watch cursor gViewerWindow->setCursor(UI_CURSOR_WAIT); diff --git a/linden/indra/newview/llpanelgeneral.cpp b/linden/indra/newview/llpanelgeneral.cpp index 07c81fd..14b3dc1 100644 --- a/linden/indra/newview/llpanelgeneral.cpp +++ b/linden/indra/newview/llpanelgeneral.cpp @@ -46,6 +46,7 @@ #include "llagent.h" #include "llpanellogin.h" #include "llviewerregion.h" +#include "viewertime.h" LLPanelGeneral::LLPanelGeneral() { @@ -100,8 +101,8 @@ BOOL LLPanelGeneral::postBuild() childSetValue("ui_scale_slider", gSavedSettings.getF32("UIScaleFactor")); childSetValue("ui_auto_scale", gSavedSettings.getBOOL("UIAutoScale")); - LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); - crash_behavior_combobox->setCurrentByIndex(gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING)); + LLComboBox* time_combobox = getChild("time_combobox"); + time_combobox->setCurrentByIndex(gSavedSettings.getU32("TimeFormat")); childSetValue("language_combobox", gSavedSettings.getString("Language")); @@ -171,8 +172,9 @@ void LLPanelGeneral::apply() gSavedSettings.setBOOL("UIAutoScale", childGetValue("ui_auto_scale")); gSavedSettings.setString("Language", childGetValue("language_combobox")); - LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); - gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, crash_behavior_combobox->getCurrentIndex()); + LLComboBox* time_combobox = getChild("time_combobox"); + gSavedSettings.setU32("TimeFormat", time_combobox->getCurrentIndex()); + gViewerTime->updateTimeFormat(time_combobox->getCurrentIndex()); // if we have no agent, we can't let them choose anything // if we have an agent, then we only let them choose if they have a choice diff --git a/linden/indra/newview/llprefsadvanced.cpp b/linden/indra/newview/llprefsadvanced.cpp index 9429d2d..6489f52 100644 --- a/linden/indra/newview/llprefsadvanced.cpp +++ b/linden/indra/newview/llprefsadvanced.cpp @@ -30,6 +30,8 @@ #include "llviewerprecompiledheaders.h" +#include "llcombobox.h" + #include "llagent.h" #include "llprefsadvanced.h" #include "llviewercontrol.h" @@ -65,6 +67,9 @@ BOOL LLPrefsAdvanced::postBuild() childSetValue("legacy_pie_menu_checkbox", gSavedSettings.getBOOL("LegacyPieEnabled")); childSetValue("language_is_public", gSavedSettings.getBOOL("LanguageIsPublic")); + LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); + crash_behavior_combobox->setCurrentByIndex(gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING)); + refresh(); return TRUE; @@ -139,6 +144,9 @@ void LLPrefsAdvanced::apply() gSavedSettings.setBOOL("LegacyPieEnabled", childGetValue("legacy_pie_menu_checkbox")); build_pie_menus(); } + + LLComboBox* crash_behavior_combobox = getChild("crash_behavior_combobox"); + gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, crash_behavior_combobox->getCurrentIndex()); } void LLPrefsAdvanced::cancel() diff --git a/linden/indra/newview/llstatusbar.cpp b/linden/indra/newview/llstatusbar.cpp index 3bd30cc..366363b 100644 --- a/linden/indra/newview/llstatusbar.cpp +++ b/linden/indra/newview/llstatusbar.cpp @@ -83,11 +83,8 @@ #include "llstring.h" #include "message.h" -// system includes -#include - - #include "hippoGridManager.h" +#include "viewertime.h" // // Globals @@ -121,10 +118,6 @@ static void onClickScripts(void*); static void onClickBuyLand(void*); static void onClickScriptDebug(void*); -std::vector LLStatusBar::sDays; -std::vector LLStatusBar::sMonths; -const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000; - LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) : LLPanel(name, LLRect(), FALSE), // not mouse opaque mBalance(0), @@ -136,10 +129,6 @@ mSquareMetersCommitted(0) setMouseOpaque(FALSE); setIsChrome(TRUE); - // size of day of the weeks and year - sDays.reserve(7); - sMonths.reserve(12); - mBalanceTimer = new LLFrameTimer(); mHealthTimer = new LLFrameTimer(); @@ -148,9 +137,6 @@ mSquareMetersCommitted(0) // status bar can never get a tab setFocusRoot(FALSE); - // build date necessary data (must do after panel built) - setupDate(); - mTextParcelName = getChild("ParcelNameText" ); mTextBalance = getChild("BalanceText" ); @@ -265,50 +251,10 @@ void LLStatusBar::refresh() mSGBandwidth->setThreshold(1, bwtotal); mSGBandwidth->setThreshold(2, bwtotal); - // *TODO: Localize / translate time - - // Get current UTC time, adjusted for the user's clock - // being off. - time_t utc_time; - utc_time = 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); - - S32 hour = internal_time->tm_hour; - S32 min = internal_time->tm_min; - - std::string am_pm = "AM"; - if (hour > 11) - { - hour -= 12; - am_pm = "PM"; - } - - std::string tz = "PST"; - if (gPacificDaylightTime) - { - tz = "PDT"; - } - // Zero hour is 12 AM - if (hour == 0) hour = 12; - std::ostringstream t; - t << std::setfill(' ') << std::setw(2) << hour << ":" - << std::setfill('0') << std::setw(2) << min - << " " << am_pm << " " << tz; - mTextTime->setText(t.str()); - - // Year starts at 1900, set the tooltip to have the date - std::ostringstream date; - date << sDays[internal_time->tm_wday] << ", " - << std::setfill('0') << std::setw(2) << internal_time->tm_mday << " " - << sMonths[internal_time->tm_mon] << " " - << internal_time->tm_year + 1900; - mTextTime->setToolTip(date.str()); + // Let's not have to reformat time everywhere, shall we? -- MC + gViewerTime->refresh(); + mTextTime->setText(gViewerTime->getCurTimeStr()); + mTextTime->setToolTip(gViewerTime->getCurDateStr()); LLRect r; const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); @@ -877,69 +823,6 @@ static void onClickBuyLand(void*) LLViewerParcelMgr::getInstance()->startBuyLand(); } -// sets the static variables necessary for the date -void LLStatusBar::setupDate() -{ - // fill the day array with what's in the xui - std::string day_list = getString("StatBarDaysOfWeek"); - size_t length = day_list.size(); - - // quick input check - if(length < MAX_DATE_STRING_LENGTH) - { - // tokenize it and put it in the array - std::string cur_word; - for(size_t i = 0; i < length; ++i) - { - if(day_list[i] == ':') - { - sDays.push_back(cur_word); - cur_word.clear(); - } - else - { - cur_word.append(1, day_list[i]); - } - } - sDays.push_back(cur_word); - } - - // fill the day array with what's in the xui - std::string month_list = getString( "StatBarMonthsOfYear" ); - length = month_list.size(); - - // quick input check - if(length < MAX_DATE_STRING_LENGTH) - { - // tokenize it and put it in the array - std::string cur_word; - for(size_t i = 0; i < length; ++i) - { - if(month_list[i] == ':') - { - sMonths.push_back(cur_word); - cur_word.clear(); - } - else - { - cur_word.append(1, month_list[i]); - } - } - sMonths.push_back(cur_word); - } - - // make sure we have at least 7 days and 12 months - if(sDays.size() < 7) - { - sDays.resize(7); - } - - if(sMonths.size() < 12) - { - sMonths.resize(12); - } -} - // static void LLStatusBar::onCommitSearch(LLUICtrl*, void* data) { diff --git a/linden/indra/newview/llstatusbar.h b/linden/indra/newview/llstatusbar.h index 8e71f75..92be319 100644 --- a/linden/indra/newview/llstatusbar.h +++ b/linden/indra/newview/llstatusbar.h @@ -47,6 +47,7 @@ class LLUICtrl; class LLUUID; class LLFrameTimer; class LLStatGraph; +class ViewerTime; // used by LCD screen class LLRegionDetails @@ -122,9 +123,6 @@ public: LLRegionDetails mRegionDetails; private: - // simple method to setup the part that holds the date - void setupDate(); - static void onCommitSearch(LLUICtrl*, void* data); static void onClickSearch(void* data); static void onClickStatGraph(void* data); @@ -147,10 +145,7 @@ private: S32 mSquareMetersCommitted; LLFrameTimer* mBalanceTimer; LLFrameTimer* mHealthTimer; - - static std::vector sDays; - static std::vector sMonths; - static const U32 MAX_DATE_STRING_LENGTH; + ViewerTime* mViewerTime; }; // *HACK: Status bar owns your cached money balance. JC diff --git a/linden/indra/newview/llviewertexteditor.cpp b/linden/indra/newview/llviewertexteditor.cpp index 832fdd6..4caf257 100644 --- a/linden/indra/newview/llviewertexteditor.cpp +++ b/linden/indra/newview/llviewertexteditor.cpp @@ -61,6 +61,7 @@ #include "llmenugl.h" #include "llappviewer.h" // for gPacificDaylightTime +#include "viewertime.h" static LLRegisterWidget r("text_editor"); @@ -1251,7 +1252,8 @@ std::string LLViewerTextEditor::getEmbeddedText() std::string LLViewerTextEditor::appendTime(bool prepend_newline) { - time_t utc_time; + // Format time according to the person's settings -- MC + /*time_t utc_time; utc_time = time_corrected(); // There's only one internal tm buffer. @@ -1261,7 +1263,15 @@ std::string LLViewerTextEditor::appendTime(bool prepend_newline) // it's daylight savings time there. timep = utc_to_pacific_time(utc_time, gPacificDaylightTime); - std::string text = llformat("[%02d:%02d] ", timep->tm_hour, timep->tm_min); + text = llformat("[%02d:%02d] ", timep->tm_hour, timep->tm_min); + appendColoredText(text, false, prepend_newline, LLColor4::grey);*/ + std::string text = llformat("[%02d:%02d", gViewerTime->getCurHour(), gViewerTime->getCurMin()); + if (!gViewerTime->getCurAMPM().empty()) + { + text += " "; + text += gViewerTime->getCurAMPM(); + } + text += "] "; appendColoredText(text, false, prepend_newline, LLColor4::grey); return text; diff --git a/linden/indra/newview/skins/default/xui/da/panel_status_bar.xml b/linden/indra/newview/skins/default/xui/da/panel_status_bar.xml index 7bc66b1..8088f54 100644 --- a/linden/indra/newview/skins/default/xui/da/panel_status_bar.xml +++ b/linden/indra/newview/skins/default/xui/da/panel_status_bar.xml @@ -11,12 +11,6 @@ 12:00 - - Søndag:Mandag:Tirsdag:Onsdag:Torsdag:Fredag:Lørdag - - - Januar:Februar:Marts:April:Maj:Juni:Juli:August:September:Oktober:November:December -