diff options
Diffstat (limited to 'linden/indra/newview/llstatusbar.cpp')
-rw-r--r-- | linden/indra/newview/llstatusbar.cpp | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/linden/indra/newview/llstatusbar.cpp b/linden/indra/newview/llstatusbar.cpp index 784765b..f0c6ea5 100644 --- a/linden/indra/newview/llstatusbar.cpp +++ b/linden/indra/newview/llstatusbar.cpp | |||
@@ -82,6 +82,7 @@ LLStatusBar *gStatusBar = NULL; | |||
82 | S32 STATUS_BAR_HEIGHT = 0; | 82 | S32 STATUS_BAR_HEIGHT = 0; |
83 | extern S32 MENU_BAR_HEIGHT; | 83 | extern S32 MENU_BAR_HEIGHT; |
84 | 84 | ||
85 | |||
85 | // TODO: these values ought to be in the XML too | 86 | // TODO: these values ought to be in the XML too |
86 | const S32 MENU_PARCEL_SPACING = 1; // Distance from right of menu item to parcel information | 87 | const S32 MENU_PARCEL_SPACING = 1; // Distance from right of menu item to parcel information |
87 | const S32 SIM_STAT_WIDTH = 8; | 88 | const S32 SIM_STAT_WIDTH = 8; |
@@ -95,6 +96,10 @@ const F32 ICON_FLASH_FREQUENCY = 2.f; | |||
95 | const S32 GRAPHIC_FUDGE = 4; | 96 | const S32 GRAPHIC_FUDGE = 4; |
96 | const S32 TEXT_HEIGHT = 18; | 97 | const S32 TEXT_HEIGHT = 18; |
97 | 98 | ||
99 | std::vector<std::string> LLStatusBar::sDays; | ||
100 | std::vector<std::string> LLStatusBar::sMonths; | ||
101 | const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000; | ||
102 | |||
98 | LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) | 103 | LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) |
99 | : LLPanel(name, LLRect(), FALSE), // not mouse opaque | 104 | : LLPanel(name, LLRect(), FALSE), // not mouse opaque |
100 | mBalance(0), | 105 | mBalance(0), |
@@ -106,6 +111,10 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) | |||
106 | mMouseOpaque = FALSE; | 111 | mMouseOpaque = FALSE; |
107 | setIsChrome(TRUE); | 112 | setIsChrome(TRUE); |
108 | 113 | ||
114 | // size of day of the weeks and year | ||
115 | sDays.reserve(7); | ||
116 | sMonths.reserve(12); | ||
117 | |||
109 | mBalanceTimer = new LLFrameTimer(); | 118 | mBalanceTimer = new LLFrameTimer(); |
110 | mHealthTimer = new LLFrameTimer(); | 119 | mHealthTimer = new LLFrameTimer(); |
111 | 120 | ||
@@ -114,6 +123,9 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) | |||
114 | // status bar can never get a tab | 123 | // status bar can never get a tab |
115 | setFocusRoot(FALSE); | 124 | setFocusRoot(FALSE); |
116 | 125 | ||
126 | // build date necessary data (must do after panel built) | ||
127 | setupDate(); | ||
128 | |||
117 | mBtnScriptOut = LLUICtrlFactory::getButtonByName( this, "scriptout" ); | 129 | mBtnScriptOut = LLUICtrlFactory::getButtonByName( this, "scriptout" ); |
118 | mBtnHealth = LLUICtrlFactory::getButtonByName( this, "health" ); | 130 | mBtnHealth = LLUICtrlFactory::getButtonByName( this, "health" ); |
119 | mBtnFly = LLUICtrlFactory::getButtonByName( this, "fly" ); | 131 | mBtnFly = LLUICtrlFactory::getButtonByName( this, "fly" ); |
@@ -128,7 +140,7 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect) | |||
128 | 140 | ||
129 | mTextHealth = LLUICtrlFactory::getTextBoxByName( this, "HealthText" ); | 141 | mTextHealth = LLUICtrlFactory::getTextBoxByName( this, "HealthText" ); |
130 | mTextTime = LLUICtrlFactory::getTextBoxByName( this, "TimeText" ); | 142 | mTextTime = LLUICtrlFactory::getTextBoxByName( this, "TimeText" ); |
131 | 143 | ||
132 | S32 x = mRect.getWidth() - 2; | 144 | S32 x = mRect.getWidth() - 2; |
133 | S32 y = 0; | 145 | S32 y = 0; |
134 | LLRect r; | 146 | LLRect r; |
@@ -265,6 +277,14 @@ void LLStatusBar::refresh() | |||
265 | << " " << am_pm << " " << tz; | 277 | << " " << am_pm << " " << tz; |
266 | mTextTime->setText(t.str().c_str()); | 278 | mTextTime->setText(t.str().c_str()); |
267 | 279 | ||
280 | // Year starts at 1900, set the tooltip to have the date | ||
281 | std::ostringstream date; | ||
282 | date << sDays[internal_time->tm_wday] << ", " | ||
283 | << std::setfill('0') << std::setw(2) << internal_time->tm_mday << " " | ||
284 | << sMonths[internal_time->tm_mon] << " " | ||
285 | << internal_time->tm_year + 1900; | ||
286 | mTextTime->setToolTip(date.str().c_str()); | ||
287 | |||
268 | LLRect r; | 288 | LLRect r; |
269 | const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); | 289 | const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); |
270 | S32 x = MENU_RIGHT + MENU_PARCEL_SPACING; | 290 | S32 x = MENU_RIGHT + MENU_PARCEL_SPACING; |
@@ -644,6 +664,69 @@ void LLStatusBar::onClickBuyLand(void*) | |||
644 | gParcelMgr->startBuyLand(); | 664 | gParcelMgr->startBuyLand(); |
645 | } | 665 | } |
646 | 666 | ||
667 | // sets the static variables necessary for the date | ||
668 | void LLStatusBar::setupDate() | ||
669 | { | ||
670 | // fill the day array with what's in the xui | ||
671 | LLString day_list = childGetText("StatBarDaysOfWeek"); | ||
672 | size_t length = day_list.size(); | ||
673 | |||
674 | // quick input check | ||
675 | if(length < MAX_DATE_STRING_LENGTH) | ||
676 | { | ||
677 | // tokenize it and put it in the array | ||
678 | LLString cur_word; | ||
679 | for(size_t i = 0; i < length; ++i) | ||
680 | { | ||
681 | if(day_list[i] == ':') | ||
682 | { | ||
683 | sDays.push_back(cur_word); | ||
684 | cur_word.clear(); | ||
685 | } | ||
686 | else | ||
687 | { | ||
688 | cur_word.append(1, day_list.c_str()[i]); | ||
689 | } | ||
690 | } | ||
691 | sDays.push_back(cur_word); | ||
692 | } | ||
693 | |||
694 | // fill the day array with what's in the xui | ||
695 | LLString month_list = childGetText( "StatBarMonthsOfYear" ); | ||
696 | length = month_list.size(); | ||
697 | |||
698 | // quick input check | ||
699 | if(length < MAX_DATE_STRING_LENGTH) | ||
700 | { | ||
701 | // tokenize it and put it in the array | ||
702 | LLString cur_word; | ||
703 | for(size_t i = 0; i < length; ++i) | ||
704 | { | ||
705 | if(month_list[i] == ':') | ||
706 | { | ||
707 | sMonths.push_back(cur_word); | ||
708 | cur_word.clear(); | ||
709 | } | ||
710 | else | ||
711 | { | ||
712 | cur_word.append(1, month_list.c_str()[i]); | ||
713 | } | ||
714 | } | ||
715 | sMonths.push_back(cur_word); | ||
716 | } | ||
717 | |||
718 | // make sure we have at least 7 days and 12 months | ||
719 | if(sDays.size() < 7) | ||
720 | { | ||
721 | sDays.resize(7); | ||
722 | } | ||
723 | |||
724 | if(sMonths.size() < 12) | ||
725 | { | ||
726 | sMonths.resize(12); | ||
727 | } | ||
728 | } | ||
729 | |||
647 | BOOL can_afford_transaction(S32 cost) | 730 | BOOL can_afford_transaction(S32 cost) |
648 | { | 731 | { |
649 | return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); | 732 | return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); |