00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llstatusbar.h"
00035
00036 #include <iomanip>
00037
00038 #include "imageids.h"
00039 #include "llfontgl.h"
00040 #include "llrect.h"
00041 #include "llerror.h"
00042 #include "llparcel.h"
00043 #include "llstring.h"
00044 #include "message.h"
00045
00046 #include "llagent.h"
00047 #include "llbutton.h"
00048 #include "llviewercontrol.h"
00049 #include "llfloaterbuycurrency.h"
00050 #include "llfloaterchat.h"
00051 #include "llfloaterdirectory.h"
00052 #include "llfloaterlagmeter.h"
00053 #include "llfloaterland.h"
00054 #include "llfloaterregioninfo.h"
00055 #include "llfloaterscriptdebug.h"
00056 #include "llhudicon.h"
00057 #include "llinventoryview.h"
00058 #include "llkeyboard.h"
00059 #include "lllineeditor.h"
00060 #include "llmenugl.h"
00061 #include "llnotify.h"
00062 #include "llimview.h"
00063 #include "lltextbox.h"
00064 #include "llui.h"
00065 #include "llviewerparceloverlay.h"
00066 #include "llviewerregion.h"
00067 #include "llviewerstats.h"
00068 #include "llviewerwindow.h"
00069 #include "llframetimer.h"
00070 #include "llvoavatar.h"
00071 #include "llresmgr.h"
00072 #include "llworld.h"
00073 #include "llstatgraph.h"
00074 #include "llviewermenu.h"
00075 #include "llviewerparcelmgr.h"
00076 #include "llviewerthrottle.h"
00077 #include "lluictrlfactory.h"
00078 #include "llvoiceclient.h"
00079
00080 #include "lltoolmgr.h"
00081 #include "llfocusmgr.h"
00082 #include "llappviewer.h"
00083
00084
00085
00086
00087
00088
00089 LLStatusBar *gStatusBar = NULL;
00090 S32 STATUS_BAR_HEIGHT = 0;
00091 extern S32 MENU_BAR_HEIGHT;
00092
00093
00094
00095 const S32 MENU_PARCEL_SPACING = 1;
00096 const S32 SIM_STAT_WIDTH = 8;
00097 const F32 SIM_WARN_FRACTION = 0.75f;
00098 const F32 SIM_FULL_FRACTION = 0.98f;
00099 const LLColor4 SIM_OK_COLOR(0.f, 1.f, 0.f, 1.f);
00100 const LLColor4 SIM_WARN_COLOR(1.f, 1.f, 0.f, 1.f);
00101 const LLColor4 SIM_FULL_COLOR(1.f, 0.f, 0.f, 1.f);
00102 const F32 ICON_TIMER_EXPIRY = 3.f;
00103 const F32 ICON_FLASH_FREQUENCY = 2.f;
00104 const S32 TEXT_HEIGHT = 18;
00105
00106 static void onClickParcelInfo(void*);
00107 static void onClickBalance(void*);
00108 static void onClickBuyCurrency(void*);
00109 static void onClickHealth(void*);
00110 static void onClickFly(void*);
00111 static void onClickPush(void*);
00112 static void onClickVoice(void*);
00113 static void onClickBuild(void*);
00114 static void onClickScripts(void*);
00115 static void onClickBuyLand(void*);
00116 static void onClickScriptDebug(void*);
00117
00118 std::vector<std::string> LLStatusBar::sDays;
00119 std::vector<std::string> LLStatusBar::sMonths;
00120 const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000;
00121
00122 LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect)
00123 : LLPanel(name, LLRect(), FALSE),
00124 mBalance(0),
00125 mHealth(100),
00126 mSquareMetersCredit(0),
00127 mSquareMetersCommitted(0)
00128 {
00129
00130 setMouseOpaque(FALSE);
00131 setIsChrome(TRUE);
00132
00133
00134 sDays.reserve(7);
00135 sMonths.reserve(12);
00136
00137 mBalanceTimer = new LLFrameTimer();
00138 mHealthTimer = new LLFrameTimer();
00139
00140 LLUICtrlFactory::getInstance()->buildPanel(this,"panel_status_bar.xml");
00141
00142
00143 setFocusRoot(FALSE);
00144
00145
00146 setupDate();
00147
00148 mTextParcelName = getChild<LLTextBox>("ParcelNameText" );
00149 mTextBalance = getChild<LLTextBox>("BalanceText" );
00150
00151 mTextHealth = getChild<LLTextBox>("HealthText" );
00152 mTextTime = getChild<LLTextBox>("TimeText" );
00153
00154 childSetAction("scriptout", onClickScriptDebug, this);
00155 childSetAction("health", onClickHealth, this);
00156 childSetAction("no_fly", onClickFly, this);
00157 childSetAction("buyland", onClickBuyLand, this );
00158 childSetAction("buycurrency", onClickBuyCurrency, this );
00159 childSetAction("no_build", onClickBuild, this );
00160 childSetAction("no_scripts", onClickScripts, this );
00161 childSetAction("restrictpush", onClickPush, this );
00162 childSetAction("status_no_voice", onClickVoice, this );
00163
00164 childSetCommitCallback("search_editor", onCommitSearch, this);
00165 childSetAction("search_btn", onClickSearch, this);
00166
00167 childSetVisible("search_editor", gSavedSettings.getBOOL("ShowSearchBar"));
00168 childSetVisible("search_btn", gSavedSettings.getBOOL("ShowSearchBar"));
00169 childSetVisible("menubar_search_bevel_bg", gSavedSettings.getBOOL("ShowSearchBar"));
00170
00171 childSetActionTextbox("ParcelNameText", onClickParcelInfo );
00172 childSetActionTextbox("BalanceText", onClickBalance );
00173
00174
00175 S32 x = getRect().getWidth() - 2;
00176 S32 y = 0;
00177 LLRect r;
00178 r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
00179 mSGBandwidth = new LLStatGraph("BandwidthGraph", r);
00180 mSGBandwidth->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
00181 mSGBandwidth->setStat(&LLViewerStats::getInstance()->mKBitStat);
00182 LLString text = childGetText("bandwidth_tooltip") + " ";
00183 LLUIString bandwidth_tooltip = text;
00184 mSGBandwidth->setLabel(bandwidth_tooltip.getString().c_str());
00185 mSGBandwidth->setUnits("Kbps");
00186 mSGBandwidth->setPrecision(0);
00187 mSGBandwidth->setMouseOpaque(FALSE);
00188 addChild(mSGBandwidth);
00189 x -= SIM_STAT_WIDTH + 2;
00190
00191 r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
00192 mSGPacketLoss = new LLStatGraph("PacketLossPercent", r);
00193 mSGPacketLoss->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
00194 mSGPacketLoss->setStat(&LLViewerStats::getInstance()->mPacketsLostPercentStat);
00195 text = childGetText("packet_loss_tooltip") + " ";
00196 LLUIString packet_loss_tooltip = text;
00197 mSGPacketLoss->setLabel(packet_loss_tooltip.getString().c_str());
00198 mSGPacketLoss->setUnits("%");
00199 mSGPacketLoss->setMin(0.f);
00200 mSGPacketLoss->setMax(5.f);
00201 mSGPacketLoss->setThreshold(0, 0.5f);
00202 mSGPacketLoss->setThreshold(1, 1.f);
00203 mSGPacketLoss->setThreshold(2, 3.f);
00204 mSGPacketLoss->setPrecision(1);
00205 mSGPacketLoss->setMouseOpaque(FALSE);
00206 mSGPacketLoss->mPerSec = FALSE;
00207 addChild(mSGPacketLoss);
00208
00209 childSetActionTextbox("stat_btn", onClickStatGraph);
00210
00211 }
00212
00213 LLStatusBar::~LLStatusBar()
00214 {
00215 delete mBalanceTimer;
00216 mBalanceTimer = NULL;
00217
00218 delete mHealthTimer;
00219 mHealthTimer = NULL;
00220
00221
00222 }
00223
00224
00225
00226
00227
00228
00229 void LLStatusBar::draw()
00230 {
00231 refresh();
00232
00233 if (isBackgroundVisible())
00234 {
00235 gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
00236 LLUI::sColorsGroup->getColor("ColorDropShadow"),
00237 LLUI::sConfigGroup->getS32("DropShadowFloater") );
00238 }
00239 LLPanel::draw();
00240 }
00241
00242
00243
00244 void LLStatusBar::refresh()
00245 {
00246
00247 F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
00248 mSGBandwidth->setMin(0.f);
00249 mSGBandwidth->setMax(bwtotal*1.25f);
00250 mSGBandwidth->setThreshold(0, bwtotal*0.75f);
00251 mSGBandwidth->setThreshold(1, bwtotal);
00252 mSGBandwidth->setThreshold(2, bwtotal);
00253
00254
00255
00256
00257
00258 U32 utc_time;
00259 utc_time = time_corrected();
00260
00261
00262 struct tm* internal_time;
00263
00264
00265
00266 internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
00267
00268 S32 hour = internal_time->tm_hour;
00269 S32 min = internal_time->tm_min;
00270
00271 std::string am_pm = "AM";
00272 if (hour > 11)
00273 {
00274 hour -= 12;
00275 am_pm = "PM";
00276 }
00277
00278 std::string tz = "PST";
00279 if (gPacificDaylightTime)
00280 {
00281 tz = "PDT";
00282 }
00283
00284 if (hour == 0) hour = 12;
00285 std::ostringstream t;
00286 t << std::setfill(' ') << std::setw(2) << hour << ":"
00287 << std::setfill('0') << std::setw(2) << min
00288 << " " << am_pm << " " << tz;
00289 mTextTime->setText(t.str());
00290
00291
00292 std::ostringstream date;
00293 date << sDays[internal_time->tm_wday] << ", "
00294 << std::setfill('0') << std::setw(2) << internal_time->tm_mday << " "
00295 << sMonths[internal_time->tm_mon] << " "
00296 << internal_time->tm_year + 1900;
00297 mTextTime->setToolTip(date.str());
00298
00299 LLRect r;
00300 const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
00301 S32 x = MENU_RIGHT + MENU_PARCEL_SPACING;
00302 S32 y = 0;
00303
00304 bool search_visible = gSavedSettings.getBOOL("ShowSearchBar");
00305
00306
00307 if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
00308 {
00309 gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
00310 }
00311
00312 LLViewerRegion *region = gAgent.getRegion();
00313 LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
00314
00315 LLRect buttonRect;
00316
00317 if (LLHUDIcon::iconsNearby())
00318 {
00319 childGetRect( "scriptout", buttonRect );
00320 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00321 childSetRect("scriptout",r);
00322 childSetVisible("scriptout", true);
00323 x += buttonRect.getWidth();
00324 }
00325 else
00326 {
00327 childSetVisible("scriptout", false);
00328 }
00329
00330 if ((region && region->getAllowDamage()) ||
00331 (parcel && parcel->getAllowDamage()) )
00332 {
00333
00334 if( mHealthTimer->hasExpired() )
00335 {
00336 childSetVisible("health", true);
00337 }
00338 else
00339 {
00340 BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
00341 childSetVisible("health", flash);
00342 }
00343 mTextHealth->setVisible(TRUE);
00344
00345
00346 childGetRect( "health", buttonRect );
00347 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00348 childSetRect("health", r);
00349 x += buttonRect.getWidth();
00350
00351 const S32 health_width = S32( LLFontGL::sSansSerifSmall->getWidth("100%") );
00352 r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
00353 mTextHealth->setRect(r);
00354 x += health_width;
00355 }
00356 else
00357 {
00358
00359 childSetVisible("health", false);
00360 mTextHealth->setVisible(FALSE);
00361 }
00362
00363 if ((region && region->getBlockFly()) ||
00364 (parcel && !parcel->getAllowFly()) )
00365 {
00366
00367 childGetRect( "no_fly", buttonRect );
00368 childSetVisible( "no_fly", true );
00369 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00370 childSetRect( "no_fly", r );
00371 x += buttonRect.getWidth();
00372 }
00373 else
00374 {
00375
00376 childSetVisible("no_fly", false);
00377 }
00378
00379 BOOL no_build = parcel && !parcel->getAllowModify();
00380 if (no_build)
00381 {
00382 childSetVisible("no_build", TRUE);
00383 childGetRect( "no_build", buttonRect );
00384
00385 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00386 childSetRect( "no_build", r );
00387 x += buttonRect.getWidth();
00388 }
00389 else
00390 {
00391 childSetVisible("no_build", FALSE);
00392 }
00393
00394 BOOL no_scripts = FALSE;
00395 if((region
00396 && ((region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
00397 || (region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)))
00398 || (parcel && !parcel->getAllowOtherScripts()))
00399 {
00400 no_scripts = TRUE;
00401 }
00402 if (no_scripts)
00403 {
00404
00405 childSetVisible("no_scripts", TRUE);
00406 childGetRect( "no_scripts", buttonRect );
00407 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00408 childSetRect( "no_scripts", r );
00409 x += buttonRect.getWidth();
00410 }
00411 else
00412 {
00413
00414 childSetVisible("no_scripts", FALSE);
00415 }
00416
00417 BOOL no_region_push = (region && region->getRestrictPushObject());
00418 BOOL no_push = no_region_push || (parcel && parcel->getRestrictPushObject());
00419 if (no_push)
00420 {
00421 childSetVisible("restrictpush", TRUE);
00422 childGetRect( "restrictpush", buttonRect );
00423 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00424 childSetRect( "restrictpush", r );
00425 x += buttonRect.getWidth();
00426 }
00427 else
00428 {
00429 childSetVisible("restrictpush", FALSE);
00430 }
00431
00432 BOOL have_voice = parcel && parcel->getVoiceEnabled();
00433 if (have_voice)
00434 {
00435 childSetVisible("status_no_voice", FALSE);
00436 }
00437 else
00438 {
00439 childSetVisible("status_no_voice", TRUE);
00440 childGetRect( "status_no_voice", buttonRect );
00441 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00442 childSetRect( "status_no_voice", r );
00443 x += buttonRect.getWidth();
00444 }
00445
00446 BOOL canBuyLand = parcel
00447 && !parcel->isPublic()
00448 && LLViewerParcelMgr::getInstance()->canAgentBuyParcel(parcel, false);
00449 childSetVisible("buyland", canBuyLand);
00450 if (canBuyLand)
00451 {
00452
00453 x += 9;
00454 childGetRect( "buyland", buttonRect );
00455 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00456 childSetRect( "buyland", r );
00457 x += buttonRect.getWidth();
00458 }
00459
00460 LLString location_name;
00461 if (region)
00462 {
00463 const LLVector3& agent_pos_region = gAgent.getPositionAgent();
00464 S32 pos_x = lltrunc( agent_pos_region.mV[VX] );
00465 S32 pos_y = lltrunc( agent_pos_region.mV[VY] );
00466 S32 pos_z = lltrunc( agent_pos_region.mV[VZ] );
00467
00468
00469 LLVector3 agent_velocity = gAgent.getVelocity();
00470 F32 velocity_mag_sq = agent_velocity.magVecSquared();
00471
00472 const F32 FLY_CUTOFF = 6.f;
00473 const F32 FLY_CUTOFF_SQ = FLY_CUTOFF * FLY_CUTOFF;
00474 const F32 WALK_CUTOFF = 1.5f;
00475 const F32 WALK_CUTOFF_SQ = WALK_CUTOFF * WALK_CUTOFF;
00476
00477 if (velocity_mag_sq > FLY_CUTOFF_SQ)
00478 {
00479 pos_x -= pos_x % 4;
00480 pos_y -= pos_y % 4;
00481 }
00482 else if (velocity_mag_sq > WALK_CUTOFF_SQ)
00483 {
00484 pos_x -= pos_x % 2;
00485 pos_y -= pos_y % 2;
00486 }
00487
00488 mRegionDetails.mTime = mTextTime->getText();
00489 mRegionDetails.mBalance = mBalance;
00490 mRegionDetails.mAccesString = region->getSimAccessString();
00491 mRegionDetails.mPing = region->getNetDetailsForLCD();
00492 if (parcel && !parcel->getName().empty())
00493 {
00494 location_name = region->getName()
00495 + llformat(" %d, %d, %d (%s) - %s",
00496 pos_x, pos_y, pos_z,
00497 region->getSimAccessString(),
00498 parcel->getName().c_str());
00499
00500
00501 mRegionDetails.mRegionName = region->getName();
00502 mRegionDetails.mParcelName = parcel->getName();
00503 mRegionDetails.mX = pos_x;
00504 mRegionDetails.mY = pos_y;
00505 mRegionDetails.mZ = pos_z;
00506 mRegionDetails.mArea = parcel->getArea();
00507 mRegionDetails.mForSale = parcel->getForSale();
00508 mRegionDetails.mTraffic = LLViewerParcelMgr::getInstance()->getDwelling();
00509
00510 if (parcel->isPublic())
00511 {
00512 mRegionDetails.mOwner = "Public";
00513 }
00514 else
00515 {
00516 if (parcel->getIsGroupOwned())
00517 {
00518 if(!parcel->getGroupID().isNull())
00519 {
00520 gCacheName->getGroupName(parcel->getGroupID(), mRegionDetails.mOwner);
00521 }
00522 else
00523 {
00524 mRegionDetails.mOwner = "Group Owned";
00525 }
00526 }
00527 else
00528 {
00529
00530 gCacheName->getFullName(parcel->getOwnerID(), mRegionDetails.mOwner);
00531 }
00532 }
00533 }
00534 else
00535 {
00536 location_name = region->getName()
00537 + llformat(" %d, %d, %d (%s)",
00538 pos_x, pos_y, pos_z,
00539 region->getSimAccessString());
00540
00541 mRegionDetails.mRegionName = region->getName();
00542 mRegionDetails.mParcelName = "Unknown";
00543
00544 mRegionDetails.mX = pos_x;
00545 mRegionDetails.mY = pos_y;
00546 mRegionDetails.mZ = pos_z;
00547 mRegionDetails.mArea = 0;
00548 mRegionDetails.mForSale = FALSE;
00549 mRegionDetails.mOwner = "Unknown";
00550 mRegionDetails.mTraffic = 0.0f;
00551 }
00552 }
00553 else
00554 {
00555
00556 location_name = "(Unknown)";
00557
00558 mRegionDetails.mRegionName = "Unknown";
00559 mRegionDetails.mParcelName = "Unknown";
00560 mRegionDetails.mAccesString = "Unknown";
00561 mRegionDetails.mX = 0;
00562 mRegionDetails.mY = 0;
00563 mRegionDetails.mZ = 0;
00564 mRegionDetails.mArea = 0;
00565 mRegionDetails.mForSale = FALSE;
00566 mRegionDetails.mOwner = "Unknown";
00567 mRegionDetails.mTraffic = 0.0f;
00568 }
00569
00570 mTextParcelName->setText(location_name);
00571
00572
00573
00574
00575
00576
00577
00578
00579 S32 new_right = getRect().getWidth();
00580 if (search_visible)
00581 {
00582 childGetRect("search_btn", r);
00583
00584
00585 new_right -= r.getWidth();
00586
00587 childGetRect("search_editor", r);
00588
00589
00590 new_right -= r.getWidth() + 6;
00591 }
00592 else
00593 {
00594 childGetRect("stat_btn", r);
00595 r.translate( new_right - r.mRight, 0);
00596 childSetRect("stat_btn", r);
00597 new_right -= r.getWidth() + 6;
00598 }
00599
00600
00601 childGetRect("BalanceText", r);
00602 r.translate( new_right - r.mRight, 0);
00603 childSetRect("BalanceText", r);
00604 new_right -= r.getWidth() - 18;
00605
00606 childGetRect("buycurrency", r);
00607 r.translate( new_right - r.mRight, 0);
00608 childSetRect("buycurrency", r);
00609 new_right -= r.getWidth() + 6;
00610
00611 childGetRect("TimeText", r);
00612
00613 r.translate( new_right - r.mRight, 0);
00614 childSetRect("TimeText", r);
00615
00616
00617
00618
00619 x += 8;
00620
00621 const S32 PARCEL_RIGHT = llmin(mTextTime->getRect().mLeft, mTextParcelName->getTextPixelWidth() + x + 5);
00622 r.set(x+4, getRect().getHeight() - 2, PARCEL_RIGHT, 0);
00623 mTextParcelName->setRect(r);
00624
00625
00626 childSetVisible("search_editor", search_visible);
00627 childSetVisible("search_btn", search_visible);
00628 childSetVisible("menubar_search_bevel_bg", search_visible);
00629 mSGBandwidth->setVisible(! search_visible);
00630 mSGPacketLoss->setVisible(! search_visible);
00631 childSetEnabled("stat_btn", ! search_visible);
00632 }
00633
00634 void LLStatusBar::setVisibleForMouselook(bool visible)
00635 {
00636 mTextBalance->setVisible(visible);
00637 mTextTime->setVisible(visible);
00638 childSetVisible("buycurrency", visible);
00639 childSetVisible("search_editor", visible);
00640 childSetVisible("search_btn", visible);
00641 mSGBandwidth->setVisible(visible);
00642 mSGPacketLoss->setVisible(visible);
00643 setBackgroundVisible(visible);
00644 }
00645
00646 void LLStatusBar::debitBalance(S32 debit)
00647 {
00648 setBalance(getBalance() - debit);
00649 }
00650
00651 void LLStatusBar::creditBalance(S32 credit)
00652 {
00653 setBalance(getBalance() + credit);
00654 }
00655
00656 void LLStatusBar::setBalance(S32 balance)
00657 {
00658 LLString money_str = LLResMgr::getInstance()->getMonetaryString( balance );
00659 LLString balance_str = "L$";
00660 balance_str += money_str;
00661 mTextBalance->setText( balance_str );
00662
00663 if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
00664 {
00665 if (mBalance > balance)
00666 make_ui_sound("UISndMoneyChangeDown");
00667 else
00668 make_ui_sound("UISndMoneyChangeUp");
00669 }
00670
00671 if( balance != mBalance )
00672 {
00673 mBalanceTimer->reset();
00674 mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
00675 mBalance = balance;
00676 }
00677 }
00678
00679 void LLStatusBar::setHealth(S32 health)
00680 {
00681
00682 mTextHealth->setText(llformat("%d%%", health));
00683
00684 if( mHealth > health )
00685 {
00686 if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
00687 {
00688 LLVOAvatar *me;
00689
00690 if ((me = gAgent.getAvatarObject()))
00691 {
00692 if (me->getSex() == SEX_FEMALE)
00693 {
00694 make_ui_sound("UISndHealthReductionF");
00695 }
00696 else
00697 {
00698 make_ui_sound("UISndHealthReductionM");
00699 }
00700 }
00701 }
00702
00703 mHealthTimer->reset();
00704 mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
00705 }
00706
00707 mHealth = health;
00708 }
00709
00710 S32 LLStatusBar::getBalance() const
00711 {
00712 return mBalance;
00713 }
00714
00715
00716 S32 LLStatusBar::getHealth() const
00717 {
00718 return mHealth;
00719 }
00720
00721 void LLStatusBar::setLandCredit(S32 credit)
00722 {
00723 mSquareMetersCredit = credit;
00724 }
00725 void LLStatusBar::setLandCommitted(S32 committed)
00726 {
00727 mSquareMetersCommitted = committed;
00728 }
00729
00730 BOOL LLStatusBar::isUserTiered() const
00731 {
00732 return (mSquareMetersCredit > 0);
00733 }
00734
00735 S32 LLStatusBar::getSquareMetersCredit() const
00736 {
00737 return mSquareMetersCredit;
00738 }
00739
00740 S32 LLStatusBar::getSquareMetersCommitted() const
00741 {
00742 return mSquareMetersCommitted;
00743 }
00744
00745 S32 LLStatusBar::getSquareMetersLeft() const
00746 {
00747 return mSquareMetersCredit - mSquareMetersCommitted;
00748 }
00749
00750 static void onClickParcelInfo(void* data)
00751 {
00752 LLViewerParcelMgr::getInstance()->selectParcelAt(gAgent.getPositionGlobal());
00753
00754 LLFloaterLand::showInstance();
00755 }
00756
00757 static void onClickBalance(void* data)
00758 {
00759 LLFloaterBuyCurrency::buyCurrency();
00760 }
00761
00762 static void onClickBuyCurrency(void* data)
00763 {
00764 LLFloaterBuyCurrency::buyCurrency();
00765 }
00766
00767 static void onClickHealth(void* )
00768 {
00769 LLNotifyBox::showXml("NotSafe");
00770 }
00771
00772 static void onClickScriptDebug(void*)
00773 {
00774 LLFloaterScriptDebug::show(LLUUID::null);
00775 }
00776
00777 static void onClickFly(void* )
00778 {
00779 LLNotifyBox::showXml("NoFly");
00780 }
00781
00782 static void onClickPush(void* )
00783 {
00784 LLNotifyBox::showXml("PushRestricted");
00785 }
00786
00787 static void onClickVoice(void* )
00788 {
00789 LLNotifyBox::showXml("NoVoice");
00790 }
00791
00792 static void onClickBuild(void*)
00793 {
00794 LLNotifyBox::showXml("NoBuild");
00795 }
00796
00797 static void onClickScripts(void*)
00798 {
00799 LLViewerRegion* region = gAgent.getRegion();
00800 if(region && region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)
00801 {
00802 LLNotifyBox::showXml("ScriptsStopped");
00803 }
00804 else if(region && region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
00805 {
00806 LLNotifyBox::showXml("ScriptsNotRunning");
00807 }
00808 else
00809 {
00810 LLNotifyBox::showXml("NoOutsideScripts");
00811 }
00812 }
00813
00814 static void onClickBuyLand(void*)
00815 {
00816 LLViewerParcelMgr::getInstance()->selectParcelAt(gAgent.getPositionGlobal());
00817 LLViewerParcelMgr::getInstance()->startBuyLand();
00818 }
00819
00820
00821 void LLStatusBar::setupDate()
00822 {
00823
00824 LLString day_list = getString("StatBarDaysOfWeek");
00825 size_t length = day_list.size();
00826
00827
00828 if(length < MAX_DATE_STRING_LENGTH)
00829 {
00830
00831 LLString cur_word;
00832 for(size_t i = 0; i < length; ++i)
00833 {
00834 if(day_list[i] == ':')
00835 {
00836 sDays.push_back(cur_word);
00837 cur_word.clear();
00838 }
00839 else
00840 {
00841 cur_word.append(1, day_list.c_str()[i]);
00842 }
00843 }
00844 sDays.push_back(cur_word);
00845 }
00846
00847
00848 LLString month_list = getString( "StatBarMonthsOfYear" );
00849 length = month_list.size();
00850
00851
00852 if(length < MAX_DATE_STRING_LENGTH)
00853 {
00854
00855 LLString cur_word;
00856 for(size_t i = 0; i < length; ++i)
00857 {
00858 if(month_list[i] == ':')
00859 {
00860 sMonths.push_back(cur_word);
00861 cur_word.clear();
00862 }
00863 else
00864 {
00865 cur_word.append(1, month_list.c_str()[i]);
00866 }
00867 }
00868 sMonths.push_back(cur_word);
00869 }
00870
00871
00872 if(sDays.size() < 7)
00873 {
00874 sDays.resize(7);
00875 }
00876
00877 if(sMonths.size() < 12)
00878 {
00879 sMonths.resize(12);
00880 }
00881 }
00882
00883
00884 void LLStatusBar::onCommitSearch(LLUICtrl*, void* data)
00885 {
00886
00887 onClickSearch(data);
00888 }
00889
00890
00891 void LLStatusBar::onClickSearch(void* data)
00892 {
00893 LLStatusBar* self = (LLStatusBar*)data;
00894 LLString search_text = self->childGetText("search_editor");
00895 LLFloaterDirectory::showFindAll(search_text);
00896 }
00897
00898
00899 void LLStatusBar::onClickStatGraph(void* data)
00900 {
00901 LLFloaterLagMeter::showInstance();
00902 }
00903
00904 BOOL can_afford_transaction(S32 cost)
00905 {
00906 return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
00907 }