aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llstatusbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llstatusbar.cpp')
-rw-r--r--linden/indra/newview/llstatusbar.cpp158
1 files changed, 99 insertions, 59 deletions
diff --git a/linden/indra/newview/llstatusbar.cpp b/linden/indra/newview/llstatusbar.cpp
index 9bbb25f..8c50eca 100644
--- a/linden/indra/newview/llstatusbar.cpp
+++ b/linden/indra/newview/llstatusbar.cpp
@@ -48,6 +48,7 @@
48#include "llviewercontrol.h" 48#include "llviewercontrol.h"
49#include "llfloaterbuycurrency.h" 49#include "llfloaterbuycurrency.h"
50#include "llfloaterchat.h" 50#include "llfloaterchat.h"
51#include "llfloaterdirectory.h" // to spawn search
51#include "llfloaterland.h" 52#include "llfloaterland.h"
52#include "llfloaterregioninfo.h" 53#include "llfloaterregioninfo.h"
53#include "llfloaterscriptdebug.h" 54#include "llfloaterscriptdebug.h"
@@ -150,53 +151,6 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect)
150 mTextHealth = LLUICtrlFactory::getTextBoxByName( this, "HealthText" ); 151 mTextHealth = LLUICtrlFactory::getTextBoxByName( this, "HealthText" );
151 mTextTime = LLUICtrlFactory::getTextBoxByName( this, "TimeText" ); 152 mTextTime = LLUICtrlFactory::getTextBoxByName( this, "TimeText" );
152 153
153 S32 x = mRect.getWidth() - 2;
154 S32 y = 0;
155 LLRect r;
156 r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
157 mSGBandwidth = new LLStatGraph("BandwidthGraph", r);
158 mSGBandwidth->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
159 mSGBandwidth->setStat(&gViewerStats->mKBitStat);
160 LLString text = childGetText("bandwidth_tooltip") + " ";
161 LLUIString bandwidth_tooltip = text; // get the text from XML until this widget is XML driven
162 mSGBandwidth->setLabel(bandwidth_tooltip.getString().c_str());
163 mSGBandwidth->setUnits("kbps");
164 mSGBandwidth->setPrecision(0);
165 addChild(mSGBandwidth);
166 x -= SIM_STAT_WIDTH + 2;
167
168 r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
169 mSGPacketLoss = new LLStatGraph("PacketLossPercent", r);
170 mSGPacketLoss->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
171 mSGPacketLoss->setStat(&gViewerStats->mPacketsLostPercentStat);
172 text = childGetText("packet_loss_tooltip") + " ";
173 LLUIString packet_loss_tooltip = text; // get the text from XML until this widget is XML driven
174 mSGPacketLoss->setLabel(packet_loss_tooltip.getString().c_str());
175 mSGPacketLoss->setUnits("%");
176 mSGPacketLoss->setMin(0.f);
177 mSGPacketLoss->setMax(5.f);
178 mSGPacketLoss->setThreshold(0, 0.5f);
179 mSGPacketLoss->setThreshold(1, 1.f);
180 mSGPacketLoss->setThreshold(2, 3.f);
181 mSGPacketLoss->setPrecision(1);
182 mSGPacketLoss->mPerSec = FALSE;
183 addChild(mSGPacketLoss);
184
185}
186
187LLStatusBar::~LLStatusBar()
188{
189 delete mBalanceTimer;
190 mBalanceTimer = NULL;
191
192 delete mHealthTimer;
193 mHealthTimer = NULL;
194
195 // LLView destructor cleans up children
196}
197
198BOOL LLStatusBar::postBuild()
199{
200 childSetAction("scriptout", onClickScriptDebug, this); 154 childSetAction("scriptout", onClickScriptDebug, this);
201 childSetAction("health", onClickHealth, this); 155 childSetAction("health", onClickHealth, this);
202 childSetAction("fly", onClickFly, this); 156 childSetAction("fly", onClickFly, this);
@@ -207,17 +161,31 @@ BOOL LLStatusBar::postBuild()
207 childSetAction("restrictpush", onClickPush, this ); 161 childSetAction("restrictpush", onClickPush, this );
208 childSetAction("status_voice", onClickVoice, this ); 162 childSetAction("status_voice", onClickVoice, this );
209 163
164 childSetCommitCallback("search_editor", onCommitSearch, this);
165 childSetAction("search_btn", onClickSearch, this);
166
210 childSetActionTextbox("ParcelNameText", onClickParcelInfo ); 167 childSetActionTextbox("ParcelNameText", onClickParcelInfo );
211 childSetActionTextbox("BalanceText", onClickBalance ); 168 childSetActionTextbox("BalanceText", onClickBalance );
169}
170
171LLStatusBar::~LLStatusBar()
172{
173 delete mBalanceTimer;
174 mBalanceTimer = NULL;
175
176 delete mHealthTimer;
177 mHealthTimer = NULL;
212 178
213 return TRUE; 179 // LLView destructor cleans up children
214} 180}
215 181
182//virtual
216EWidgetType LLStatusBar::getWidgetType() const 183EWidgetType LLStatusBar::getWidgetType() const
217{ 184{
218 return WIDGET_TYPE_STATUS_BAR; 185 return WIDGET_TYPE_STATUS_BAR;
219} 186}
220 187
188//virtual
221LLString LLStatusBar::getWidgetTag() const 189LLString LLStatusBar::getWidgetTag() const
222{ 190{
223 return LL_STATUS_BAR_TAG; 191 return LL_STATUS_BAR_TAG;
@@ -245,13 +213,6 @@ void LLStatusBar::draw()
245// Per-frame updates of visibility 213// Per-frame updates of visibility
246void LLStatusBar::refresh() 214void LLStatusBar::refresh()
247{ 215{
248 F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
249 mSGBandwidth->setMin(0.f);
250 mSGBandwidth->setMax(bwtotal*1.25f);
251 mSGBandwidth->setThreshold(0, bwtotal*0.75f);
252 mSGBandwidth->setThreshold(1, bwtotal);
253 mSGBandwidth->setThreshold(2, bwtotal);
254
255 // *TODO: Localize / translate time 216 // *TODO: Localize / translate time
256 217
257 // Get current UTC time, adjusted for the user's clock 218 // Get current UTC time, adjusted for the user's clock
@@ -464,6 +425,10 @@ void LLStatusBar::refresh()
464 pos_y -= pos_y % 2; 425 pos_y -= pos_y % 2;
465 } 426 }
466 427
428 mRegionDetails.mTime = mTextTime->getText();
429 mRegionDetails.mBalance = mBalance;
430 mRegionDetails.mAccesString = (char *)region->getSimAccessString();
431 mRegionDetails.mPing = region->getNetDetailsForLCD();
467 if (parcel && !parcel->getName().empty()) 432 if (parcel && !parcel->getName().empty())
468 { 433 {
469 location_name = region->getName() 434 location_name = region->getName()
@@ -471,6 +436,43 @@ void LLStatusBar::refresh()
471 pos_x, pos_y, pos_z, 436 pos_x, pos_y, pos_z,
472 region->getSimAccessString(), 437 region->getSimAccessString(),
473 parcel->getName().c_str()); 438 parcel->getName().c_str());
439
440 // keep these around for the LCD to use
441 mRegionDetails.mRegionName = region->getName();
442 mRegionDetails.mParcelName = (char *)parcel->getName().c_str();
443 mRegionDetails.mX = pos_x;
444 mRegionDetails.mY = pos_y;
445 mRegionDetails.mZ = pos_z;
446 mRegionDetails.mArea = parcel->getArea();
447 mRegionDetails.mForSale = parcel->getForSale();
448 mRegionDetails.mTraffic = gParcelMgr->getDwelling();
449
450 if (parcel->isPublic())
451 {
452 snprintf(mRegionDetails.mOwner, MAX_STRING, "Public");
453 }
454 else
455 {
456 if (parcel->getIsGroupOwned())
457 {
458 if(!parcel->getGroupID().isNull())
459 {
460 gCacheName->getGroupName(parcel->getGroupID(), mRegionDetails.mOwner);
461 }
462 else
463 {
464 snprintf(mRegionDetails.mOwner, MAX_STRING, "Group Owned");
465 }
466 }
467 else
468 {
469 // Figure out the owner's name
470 char owner_first[MAX_STRING]; /*Flawfinder: ignore*/
471 char owner_last[MAX_STRING]; /*Flawfinder: ignore*/
472 gCacheName->getName(parcel->getOwnerID(), owner_first, owner_last);
473 snprintf(mRegionDetails.mOwner, MAX_STRING, "%s %s", owner_first, owner_last); /* Flawfinder: ignore */
474 }
475 }
474 } 476 }
475 else 477 else
476 { 478 {
@@ -478,12 +480,34 @@ void LLStatusBar::refresh()
478 + llformat(" %d, %d, %d (%s)", 480 + llformat(" %d, %d, %d (%s)",
479 pos_x, pos_y, pos_z, 481 pos_x, pos_y, pos_z,
480 region->getSimAccessString()); 482 region->getSimAccessString());
483 // keep these around for the LCD to use
484 mRegionDetails.mRegionName = region->getName();
485 mRegionDetails.mParcelName = "Unknown";
486
487 mRegionDetails.mX = pos_x;
488 mRegionDetails.mY = pos_y;
489 mRegionDetails.mZ = pos_z;
490 mRegionDetails.mArea = 0;
491 mRegionDetails.mForSale = FALSE;
492 snprintf(mRegionDetails.mOwner, MAX_STRING, "Unknown");
493 mRegionDetails.mTraffic = 0.0f;
481 } 494 }
482 } 495 }
483 else 496 else
484 { 497 {
485 // no region 498 // no region
486 location_name = "(Unknown)"; 499 location_name = "(Unknown)";
500 // keep these around for the LCD to use
501 mRegionDetails.mRegionName = LLString("Unknown");
502 mRegionDetails.mParcelName = "Unknown";
503 mRegionDetails.mAccesString = "Unknown";
504 mRegionDetails.mX = 0;
505 mRegionDetails.mY = 0;
506 mRegionDetails.mZ = 0;
507 mRegionDetails.mArea = 0;
508 mRegionDetails.mForSale = FALSE;
509 snprintf(mRegionDetails.mOwner, MAX_STRING, "Unknown");
510 mRegionDetails.mTraffic = 0.0f;
487 } 511 }
488 mTextParcelName->setText(location_name); 512 mTextParcelName->setText(location_name);
489 513
@@ -499,9 +523,9 @@ void LLStatusBar::setVisibleForMouselook(bool visible)
499{ 523{
500 mTextBalance->setVisible(visible); 524 mTextBalance->setVisible(visible);
501 mTextTime->setVisible(visible); 525 mTextTime->setVisible(visible);
502 mSGBandwidth->setVisible(visible);
503 mSGPacketLoss->setVisible(visible);
504 childSetVisible("buycurrency", visible); 526 childSetVisible("buycurrency", visible);
527 childSetVisible("search_editor", visible);
528 childSetVisible("search_btn", visible);
505 setBackgroundVisible(visible); 529 setBackgroundVisible(visible);
506} 530}
507 531
@@ -517,8 +541,9 @@ void LLStatusBar::creditBalance(S32 credit)
517 541
518void LLStatusBar::setBalance(S32 balance) 542void LLStatusBar::setBalance(S32 balance)
519{ 543{
520 LLString balance_str; 544 LLString money_str = gResMgr->getMonetaryString( balance );
521 gResMgr->getMonetaryString( balance_str, balance ); 545 LLString balance_str = "L$";
546 balance_str += money_str;
522 mTextBalance->setText( balance_str ); 547 mTextBalance->setText( balance_str );
523 548
524 if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold"))) 549 if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
@@ -742,6 +767,21 @@ void LLStatusBar::setupDate()
742 } 767 }
743} 768}
744 769
770// static
771void LLStatusBar::onCommitSearch(LLUICtrl*, void* data)
772{
773 // committing is the same as clicking "search"
774 onClickSearch(data);
775}
776
777// static
778void LLStatusBar::onClickSearch(void* data)
779{
780 LLStatusBar* self = (LLStatusBar*)data;
781 LLString search_text = self->childGetText("search_editor");
782 LLFloaterDirectory::showFindAll(search_text);
783}
784
745BOOL can_afford_transaction(S32 cost) 785BOOL can_afford_transaction(S32 cost)
746{ 786{
747 return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); 787 return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));