aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llstatusbar.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llstatusbar.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llstatusbar.cpp')
-rw-r--r--linden/indra/newview/llstatusbar.cpp148
1 files changed, 130 insertions, 18 deletions
diff --git a/linden/indra/newview/llstatusbar.cpp b/linden/indra/newview/llstatusbar.cpp
index bdaf133..4e31151 100644
--- a/linden/indra/newview/llstatusbar.cpp
+++ b/linden/indra/newview/llstatusbar.cpp
@@ -49,6 +49,7 @@
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 "llfloaterdirectory.h" // to spawn search
52#include "llfloaterlagmeter.h"
52#include "llfloaterland.h" 53#include "llfloaterland.h"
53#include "llfloaterregioninfo.h" 54#include "llfloaterregioninfo.h"
54#include "llfloaterscriptdebug.h" 55#include "llfloaterscriptdebug.h"
@@ -126,7 +127,7 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect)
126 mSquareMetersCommitted(0) 127 mSquareMetersCommitted(0)
127{ 128{
128 // status bar can possible overlay menus? 129 // status bar can possible overlay menus?
129 mMouseOpaque = FALSE; 130 setMouseOpaque(FALSE);
130 setIsChrome(TRUE); 131 setIsChrome(TRUE);
131 132
132 // size of day of the weeks and year 133 // size of day of the weeks and year
@@ -163,8 +164,49 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect)
163 childSetCommitCallback("search_editor", onCommitSearch, this); 164 childSetCommitCallback("search_editor", onCommitSearch, this);
164 childSetAction("search_btn", onClickSearch, this); 165 childSetAction("search_btn", onClickSearch, this);
165 166
167 childSetVisible("search_editor", gSavedSettings.getBOOL("ShowSearchBar"));
168 childSetVisible("search_btn", gSavedSettings.getBOOL("ShowSearchBar"));
169
166 childSetActionTextbox("ParcelNameText", onClickParcelInfo ); 170 childSetActionTextbox("ParcelNameText", onClickParcelInfo );
167 childSetActionTextbox("BalanceText", onClickBalance ); 171 childSetActionTextbox("BalanceText", onClickBalance );
172
173 // Adding Net Stat Graph
174 S32 x = getRect().getWidth() - 2;
175 S32 y = 0;
176 LLRect r;
177 r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
178 mSGBandwidth = new LLStatGraph("BandwidthGraph", r);
179 mSGBandwidth->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
180 mSGBandwidth->setStat(&gViewerStats->mKBitStat);
181 LLString text = childGetText("bandwidth_tooltip") + " ";
182 LLUIString bandwidth_tooltip = text; // get the text from XML until this widget is XML driven
183 mSGBandwidth->setLabel(bandwidth_tooltip.getString().c_str());
184 mSGBandwidth->setUnits("Kbps");
185 mSGBandwidth->setPrecision(0);
186 mSGBandwidth->setMouseOpaque(FALSE);
187 addChild(mSGBandwidth);
188 x -= SIM_STAT_WIDTH + 2;
189
190 r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
191 mSGPacketLoss = new LLStatGraph("PacketLossPercent", r);
192 mSGPacketLoss->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
193 mSGPacketLoss->setStat(&gViewerStats->mPacketsLostPercentStat);
194 text = childGetText("packet_loss_tooltip") + " ";
195 LLUIString packet_loss_tooltip = text; // get the text from XML until this widget is XML driven
196 mSGPacketLoss->setLabel(packet_loss_tooltip.getString().c_str());
197 mSGPacketLoss->setUnits("%");
198 mSGPacketLoss->setMin(0.f);
199 mSGPacketLoss->setMax(5.f);
200 mSGPacketLoss->setThreshold(0, 0.5f);
201 mSGPacketLoss->setThreshold(1, 1.f);
202 mSGPacketLoss->setThreshold(2, 3.f);
203 mSGPacketLoss->setPrecision(1);
204 mSGPacketLoss->setMouseOpaque(FALSE);
205 mSGPacketLoss->mPerSec = FALSE;
206 addChild(mSGPacketLoss);
207
208 childSetActionTextbox("stat_btn", onClickStatGraph);
209
168} 210}
169 211
170LLStatusBar::~LLStatusBar() 212LLStatusBar::~LLStatusBar()
@@ -199,9 +241,9 @@ void LLStatusBar::draw()
199{ 241{
200 refresh(); 242 refresh();
201 243
202 if (mBgVisible) 244 if (isBackgroundVisible())
203 { 245 {
204 gl_drop_shadow(0, mRect.getHeight(), mRect.getWidth(), 0, 246 gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
205 LLUI::sColorsGroup->getColor("ColorDropShadow"), 247 LLUI::sColorsGroup->getColor("ColorDropShadow"),
206 LLUI::sConfigGroup->getS32("DropShadowFloater") ); 248 LLUI::sConfigGroup->getS32("DropShadowFloater") );
207 } 249 }
@@ -212,6 +254,14 @@ void LLStatusBar::draw()
212// Per-frame updates of visibility 254// Per-frame updates of visibility
213void LLStatusBar::refresh() 255void LLStatusBar::refresh()
214{ 256{
257 // Adding Net Stat Meter back in
258 F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
259 mSGBandwidth->setMin(0.f);
260 mSGBandwidth->setMax(bwtotal*1.25f);
261 mSGBandwidth->setThreshold(0, bwtotal*0.75f);
262 mSGBandwidth->setThreshold(1, bwtotal);
263 mSGBandwidth->setThreshold(2, bwtotal);
264
215 // *TODO: Localize / translate time 265 // *TODO: Localize / translate time
216 266
217 // Get current UTC time, adjusted for the user's clock 267 // Get current UTC time, adjusted for the user's clock
@@ -262,6 +312,8 @@ void LLStatusBar::refresh()
262 S32 x = MENU_RIGHT + MENU_PARCEL_SPACING; 312 S32 x = MENU_RIGHT + MENU_PARCEL_SPACING;
263 S32 y = 0; 313 S32 y = 0;
264 314
315 bool search_visible = gSavedSettings.getBOOL("ShowSearchBar");
316
265 // reshape menu bar to its content's width 317 // reshape menu bar to its content's width
266 if (MENU_RIGHT != gMenuBarView->getRect().getWidth()) 318 if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
267 { 319 {
@@ -454,7 +506,7 @@ void LLStatusBar::refresh()
454 506
455 mRegionDetails.mTime = mTextTime->getText(); 507 mRegionDetails.mTime = mTextTime->getText();
456 mRegionDetails.mBalance = mBalance; 508 mRegionDetails.mBalance = mBalance;
457 mRegionDetails.mAccesString = (char *)region->getSimAccessString(); 509 mRegionDetails.mAccesString = region->getSimAccessString();
458 mRegionDetails.mPing = region->getNetDetailsForLCD(); 510 mRegionDetails.mPing = region->getNetDetailsForLCD();
459 if (parcel && !parcel->getName().empty()) 511 if (parcel && !parcel->getName().empty())
460 { 512 {
@@ -466,7 +518,7 @@ void LLStatusBar::refresh()
466 518
467 // keep these around for the LCD to use 519 // keep these around for the LCD to use
468 mRegionDetails.mRegionName = region->getName(); 520 mRegionDetails.mRegionName = region->getName();
469 mRegionDetails.mParcelName = (char *)parcel->getName().c_str(); 521 mRegionDetails.mParcelName = parcel->getName();
470 mRegionDetails.mX = pos_x; 522 mRegionDetails.mX = pos_x;
471 mRegionDetails.mY = pos_y; 523 mRegionDetails.mY = pos_y;
472 mRegionDetails.mZ = pos_z; 524 mRegionDetails.mZ = pos_z;
@@ -476,7 +528,7 @@ void LLStatusBar::refresh()
476 528
477 if (parcel->isPublic()) 529 if (parcel->isPublic())
478 { 530 {
479 snprintf(mRegionDetails.mOwner, MAX_STRING, "Public"); 531 mRegionDetails.mOwner = "Public";
480 } 532 }
481 else 533 else
482 { 534 {
@@ -488,16 +540,13 @@ void LLStatusBar::refresh()
488 } 540 }
489 else 541 else
490 { 542 {
491 snprintf(mRegionDetails.mOwner, MAX_STRING, "Group Owned"); 543 mRegionDetails.mOwner = "Group Owned";
492 } 544 }
493 } 545 }
494 else 546 else
495 { 547 {
496 // Figure out the owner's name 548 // Figure out the owner's name
497 char owner_first[MAX_STRING]; /*Flawfinder: ignore*/ 549 gCacheName->getFullName(parcel->getOwnerID(), mRegionDetails.mOwner);
498 char owner_last[MAX_STRING]; /*Flawfinder: ignore*/
499 gCacheName->getName(parcel->getOwnerID(), owner_first, owner_last);
500 snprintf(mRegionDetails.mOwner, MAX_STRING, "%s %s", owner_first, owner_last); /* Flawfinder: ignore */
501 } 550 }
502 } 551 }
503 } 552 }
@@ -516,7 +565,7 @@ void LLStatusBar::refresh()
516 mRegionDetails.mZ = pos_z; 565 mRegionDetails.mZ = pos_z;
517 mRegionDetails.mArea = 0; 566 mRegionDetails.mArea = 0;
518 mRegionDetails.mForSale = FALSE; 567 mRegionDetails.mForSale = FALSE;
519 snprintf(mRegionDetails.mOwner, MAX_STRING, "Unknown"); 568 mRegionDetails.mOwner = "Unknown";
520 mRegionDetails.mTraffic = 0.0f; 569 mRegionDetails.mTraffic = 0.0f;
521 } 570 }
522 } 571 }
@@ -525,7 +574,7 @@ void LLStatusBar::refresh()
525 // no region 574 // no region
526 location_name = "(Unknown)"; 575 location_name = "(Unknown)";
527 // keep these around for the LCD to use 576 // keep these around for the LCD to use
528 mRegionDetails.mRegionName = LLString("Unknown"); 577 mRegionDetails.mRegionName = "Unknown";
529 mRegionDetails.mParcelName = "Unknown"; 578 mRegionDetails.mParcelName = "Unknown";
530 mRegionDetails.mAccesString = "Unknown"; 579 mRegionDetails.mAccesString = "Unknown";
531 mRegionDetails.mX = 0; 580 mRegionDetails.mX = 0;
@@ -533,17 +582,72 @@ void LLStatusBar::refresh()
533 mRegionDetails.mZ = 0; 582 mRegionDetails.mZ = 0;
534 mRegionDetails.mArea = 0; 583 mRegionDetails.mArea = 0;
535 mRegionDetails.mForSale = FALSE; 584 mRegionDetails.mForSale = FALSE;
536 snprintf(mRegionDetails.mOwner, MAX_STRING, "Unknown"); 585 mRegionDetails.mOwner = "Unknown";
537 mRegionDetails.mTraffic = 0.0f; 586 mRegionDetails.mTraffic = 0.0f;
538 } 587 }
588
539 mTextParcelName->setText(location_name); 589 mTextParcelName->setText(location_name);
540 590
591
592
593 // x = right edge
594 // loop through: stat graphs, search btn, search text editor, money, buy money, clock
595 // adjust rect
596 // finally adjust parcel name rect
597
598 S32 new_right = getRect().getWidth();
599 if (search_visible)
600 {
601 childGetRect("search_btn", r);
602 r.translate( new_right - r.mRight, 0);
603 childSetRect("search_btn", r);
604 new_right -= r.getWidth();
605
606 childGetRect("search_editor", r);
607 r.translate( new_right - r.mRight, 0);
608 childSetRect("search_editor", r);
609 new_right -= r.getWidth() + 6;
610
611 }
612 else
613 {
614 childGetRect("stat_btn", r);
615 r.translate( new_right - r.mRight, 0);
616 childSetRect("stat_btn", r);
617 new_right -= r.getWidth() + 6;
618 }
619
620 // Set rects of money, buy money, time
621 childGetRect("BalanceText", r);
622 r.translate( new_right - r.mRight, 0);
623 childSetRect("BalanceText", r);
624 new_right -= r.getWidth() - 18;
625
626 childGetRect("buycurrency", r);
627 r.translate( new_right - r.mRight, 0);
628 childSetRect("buycurrency", r);
629 new_right -= r.getWidth() + 6;
630
631 childGetRect("TimeText", r);
632 // mTextTime->getTextPixelWidth();
633 r.translate( new_right - r.mRight, 0);
634 childSetRect("TimeText", r);
635 // new_right -= r.getWidth() + MENU_PARCEL_SPACING;
636
637
541 // Adjust region name and parcel name 638 // Adjust region name and parcel name
542 x += 8; 639 x += 8;
543 640
544 const S32 PARCEL_RIGHT = llmin(mTextTime->getRect().mLeft, mTextParcelName->getTextPixelWidth() + x + 5); 641 const S32 PARCEL_RIGHT = llmin(mTextTime->getRect().mLeft, mTextParcelName->getTextPixelWidth() + x + 5);
545 r.set(x+4, mRect.getHeight() - 2, PARCEL_RIGHT, 0); 642 r.set(x+4, getRect().getHeight() - 2, PARCEL_RIGHT, 0);
546 mTextParcelName->setRect(r); 643 mTextParcelName->setRect(r);
644
645 // Set search bar visibility
646 childSetVisible("search_editor", search_visible);
647 childSetVisible("search_btn", search_visible);
648 mSGBandwidth->setVisible(! search_visible);
649 mSGPacketLoss->setVisible(! search_visible);
650 childSetEnabled("stat_btn", ! search_visible);
547} 651}
548 652
549void LLStatusBar::setVisibleForMouselook(bool visible) 653void LLStatusBar::setVisibleForMouselook(bool visible)
@@ -553,6 +657,8 @@ void LLStatusBar::setVisibleForMouselook(bool visible)
553 childSetVisible("buycurrency", visible); 657 childSetVisible("buycurrency", visible);
554 childSetVisible("search_editor", visible); 658 childSetVisible("search_editor", visible);
555 childSetVisible("search_btn", visible); 659 childSetVisible("search_btn", visible);
660 mSGBandwidth->setVisible(visible);
661 mSGPacketLoss->setVisible(visible);
556 setBackgroundVisible(visible); 662 setBackgroundVisible(visible);
557} 663}
558 664
@@ -664,7 +770,7 @@ static void onClickParcelInfo(void* data)
664{ 770{
665 gParcelMgr->selectParcelAt(gAgent.getPositionGlobal()); 771 gParcelMgr->selectParcelAt(gAgent.getPositionGlobal());
666 772
667 LLFloaterLand::show(); 773 LLFloaterLand::showInstance();
668} 774}
669 775
670static void onClickBalance(void* data) 776static void onClickBalance(void* data)
@@ -734,7 +840,7 @@ static void onClickBuyLand(void*)
734void LLStatusBar::setupDate() 840void LLStatusBar::setupDate()
735{ 841{
736 // fill the day array with what's in the xui 842 // fill the day array with what's in the xui
737 LLString day_list = getFormattedUIString("StatBarDaysOfWeek"); 843 LLString day_list = getString("StatBarDaysOfWeek");
738 size_t length = day_list.size(); 844 size_t length = day_list.size();
739 845
740 // quick input check 846 // quick input check
@@ -758,7 +864,7 @@ void LLStatusBar::setupDate()
758 } 864 }
759 865
760 // fill the day array with what's in the xui 866 // fill the day array with what's in the xui
761 LLString month_list = getFormattedUIString( "StatBarMonthsOfYear" ); 867 LLString month_list = getString( "StatBarMonthsOfYear" );
762 length = month_list.size(); 868 length = month_list.size();
763 869
764 // quick input check 870 // quick input check
@@ -808,6 +914,12 @@ void LLStatusBar::onClickSearch(void* data)
808 LLFloaterDirectory::showFindAll(search_text); 914 LLFloaterDirectory::showFindAll(search_text);
809} 915}
810 916
917// static
918void LLStatusBar::onClickStatGraph(void* data)
919{
920 LLFloaterLagMeter::show(data);
921}
922
811BOOL can_afford_transaction(S32 cost) 923BOOL can_afford_transaction(S32 cost)
812{ 924{
813 return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); 925 return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));