diff options
Diffstat (limited to 'indra/newview/llstatusbar.cpp')
-rw-r--r-- | indra/newview/llstatusbar.cpp | 219 |
1 files changed, 42 insertions, 177 deletions
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index c02559b209..0cf2b74f9c 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -2,31 +2,25 @@ * @file llstatusbar.cpp * @brief LLStatusBar class implementation * -* $LicenseInfo:firstyear=2002&license=viewergpl$ -* -* Copyright (c) 2002-2009, Linden Research, Inc. -* +* $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code -* The source code in this file ("Source Code") is provided by Linden Lab -* to you under the terms of the GNU General Public License, version 2.0 -* ("GPL"), unless you have obtained a separate licensing agreement -* ("Other License"), formally executed by you and Linden Lab. Terms of -* the GPL can be found in doc/GPL-license.txt in this distribution, or -* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* Copyright (C) 2010, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. * -* There are special exceptions to the terms and conditions of the GPL as -* it is applied to this Source Code. View the full text of the exception -* in the file doc/FLOSS-exception.txt in this software distribution, or -* online at -* http://secondlifegrid.net/programs/open_source/licensing/flossexception +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. * -* By copying, modifying or distributing this software, you acknowledge -* that you have read and understood your obligations described above, -* and agree to abide by those obligations. +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * -* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO -* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, -* COMPLETENESS OR PERFORMANCE. +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -111,14 +105,8 @@ const F32 ICON_TIMER_EXPIRY = 3.f; // How long the balance and health icons sho const F32 ICON_FLASH_FREQUENCY = 2.f; const S32 TEXT_HEIGHT = 18; -static void onClickHealth(void*); -static void onClickScriptDebug(void*); static void onClickVolume(void*); -std::vector<std::string> LLStatusBar::sDays; -std::vector<std::string> LLStatusBar::sMonths; -const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000; - LLStatusBar::LLStatusBar(const LLRect& rect) : LLPanel(), mTextTime(NULL), @@ -135,10 +123,6 @@ LLStatusBar::LLStatusBar(const LLRect& rect) // status bar can possible overlay menus? setMouseOpaque(FALSE); - // size of day of the weeks and year - sDays.reserve(7); - sMonths.reserve(12); - mBalanceTimer = new LLFrameTimer(); mHealthTimer = new LLFrameTimer(); @@ -177,9 +161,6 @@ BOOL LLStatusBar::postBuild() { gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3)); - // build date necessary data (must do after panel built) - setupDate(); - mTextTime = getChild<LLTextBox>("TimeText" ); getChild<LLUICtrl>("buyL")->setCommitCallback( @@ -195,9 +176,6 @@ BOOL LLStatusBar::postBuild() gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); - childSetAction("scriptout", onClickScriptDebug, this); - childSetAction("health", onClickHealth, this); - // Adding Net Stat Graph S32 x = getRect().getWidth() - 2; S32 y = 0; @@ -235,8 +213,6 @@ BOOL LLStatusBar::postBuild() mSGPacketLoss->mPerSec = FALSE; addChild(mSGPacketLoss); - childSetActionTextbox("stat_btn", onClickStatGraph); - mPanelVolumePulldown = new LLPanelVolumePulldown(); addChild(mPanelVolumePulldown); mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); @@ -247,14 +223,17 @@ BOOL LLStatusBar::postBuild() mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); mPanelNearByMedia->setVisible(FALSE); + mScriptOut = getChildView("scriptout"); + return TRUE; } // Per-frame updates of visibility void LLStatusBar::refresh() { - bool net_stats_visible = gSavedSettings.getBOOL("ShowNetStats"); - + static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false); + bool net_stats_visible = show_net_stats; + if (net_stats_visible) { // Adding Net Stat Meter back in @@ -266,26 +245,30 @@ void LLStatusBar::refresh() mSGBandwidth->setThreshold(2, bwtotal); } - // Get current UTC time, adjusted for the user's clock - // being off. - time_t utc_time; - utc_time = time_corrected(); - - std::string timeStr = getString("time"); - LLSD substitution; - substitution["datetime"] = (S32) utc_time; - LLStringUtil::format (timeStr, substitution); - mTextTime->setText(timeStr); - - // set the tooltip to have the date - std::string dtStr = getString("timeTooltip"); - LLStringUtil::format (dtStr, substitution); - mTextTime->setToolTip (dtStr); + // update clock every 10 seconds + if(mClockUpdateTimer.getElapsedTimeF32() > 10.f) + { + mClockUpdateTimer.reset(); + + // Get current UTC time, adjusted for the user's clock + // being off. + time_t utc_time; + utc_time = time_corrected(); + + std::string timeStr = getString("time"); + LLSD substitution; + substitution["datetime"] = (S32) utc_time; + LLStringUtil::format (timeStr, substitution); + mTextTime->setText(timeStr); + + // set the tooltip to have the date + std::string dtStr = getString("timeTooltip"); + LLStringUtil::format (dtStr, substitution); + mTextTime->setToolTip (dtStr); + } LLRect r; const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); - S32 x = MENU_RIGHT + MENU_PARCEL_SPACING; - S32 y = 0; // reshape menu bar to its content's width if (MENU_RIGHT != gMenuBarView->getRect().getWidth()) @@ -293,48 +276,9 @@ void LLStatusBar::refresh() gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight()); } - LLViewerRegion *region = gAgent.getRegion(); - LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - - LLRect buttonRect; - - if (LLHUDIcon::iconsNearby()) - { - childGetRect( "scriptout", buttonRect ); - r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight()); - childSetRect("scriptout",r); - childSetVisible("scriptout", true); - x += buttonRect.getWidth(); - } - else - { - childSetVisible("scriptout", false); - } - - if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK && - ((region && region->getAllowDamage()) || (parcel && parcel->getAllowDamage()))) - { - // set visibility based on flashing - if( mHealthTimer->hasExpired() ) - { - childSetVisible("health", true); - } - else - { - BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1; - childSetVisible("health", flash); - } - - // Health - childGetRect( "health", buttonRect ); - r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight()); - childSetRect("health", r); - x += buttonRect.getWidth(); - } - mSGBandwidth->setVisible(net_stats_visible); mSGPacketLoss->setVisible(net_stats_visible); - childSetEnabled("stat_btn", net_stats_visible); + getChildView("stat_btn")->setEnabled(net_stats_visible); // update the master volume button state bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); @@ -499,16 +443,6 @@ void LLStatusBar::onClickBuyCurrency() LLBuyCurrencyHTML::openCurrencyFloater(); } -static void onClickHealth(void* ) -{ - LLNotificationsUtil::add("NotSafe"); -} - -static void onClickScriptDebug(void*) -{ - LLFloaterScriptDebug::show(LLUUID::null); -} - void LLStatusBar::onMouseEnterVolume() { LLButton* volbtn = getChild<LLButton>( "volume_btn" ); @@ -570,75 +504,6 @@ void LLStatusBar::onClickMediaToggle(void* data) LLViewerMedia::setAllMediaEnabled(enable); } -// 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::onClickStatGraph(void* data) -{ - LLFloaterReg::showInstance("lagmeter"); -} - BOOL can_afford_transaction(S32 cost) { return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); |