diff options
Diffstat (limited to 'indra/newview/llstatusbar.cpp')
-rw-r--r-- | indra/newview/llstatusbar.cpp | 237 |
1 files changed, 33 insertions, 204 deletions
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 364214b9e7..8c2372ee74 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -61,7 +61,7 @@ #include "llviewerstats.h" #include "llviewerwindow.h" #include "llframetimer.h" -#include "llvoavatar.h" +#include "llvoavatarself.h" #include "llresmgr.h" #include "llworld.h" #include "llstatgraph.h" @@ -93,7 +93,7 @@ // Globals // LLStatusBar *gStatusBar = NULL; -S32 STATUS_BAR_HEIGHT = 0; +S32 STATUS_BAR_HEIGHT = 26; extern S32 MENU_BAR_HEIGHT; @@ -109,8 +109,6 @@ 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 onClickParcelInfo(void*); -static void onClickBalance(void*); static void onClickBuyCurrency(void*); static void onClickHealth(void*); static void onClickFly(void*); @@ -153,17 +151,16 @@ LLStatusBar::LLStatusBar(const LLRect& rect) // build date necessary data (must do after panel built) setupDate(); - mTextParcelName = getChild<LLTextBox>("ParcelNameText" ); - mTextBalance = getChild<LLTextBox>("BalanceText" ); - mTextHealth = getChild<LLTextBox>("HealthText" ); mTextTime = getChild<LLTextBox>("TimeText" ); + + mBtnBuyCurrency = getChild<LLButton>( "buycurrency" ); + mBtnBuyCurrency->setClickedCallback( onClickBuyCurrency, this ); childSetAction("scriptout", onClickScriptDebug, this); childSetAction("health", onClickHealth, this); childSetAction("no_fly", onClickFly, this); childSetAction("buyland", onClickBuyLand, this ); - childSetAction("buycurrency", onClickBuyCurrency, this ); childSetAction("no_build", onClickBuild, this ); childSetAction("no_scripts", onClickScripts, this ); childSetAction("restrictpush", onClickPush, this ); @@ -176,9 +173,6 @@ LLStatusBar::LLStatusBar(const LLRect& rect) childSetVisible("search_btn", gSavedSettings.getBOOL("ShowSearchBar")); childSetVisible("menubar_search_bevel_bg", gSavedSettings.getBOOL("ShowSearchBar")); - childSetActionTextbox("ParcelNameText", onClickParcelInfo ); - childSetActionTextbox("BalanceText", onClickBalance ); - // Adding Net Stat Graph S32 x = getRect().getWidth() - 2; S32 y = 0; @@ -254,13 +248,18 @@ void LLStatusBar::draw() // Per-frame updates of visibility void LLStatusBar::refresh() { - // Adding Net Stat Meter back in - F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f; - mSGBandwidth->setMin(0.f); - mSGBandwidth->setMax(bwtotal*1.25f); - mSGBandwidth->setThreshold(0, bwtotal*0.75f); - mSGBandwidth->setThreshold(1, bwtotal); - mSGBandwidth->setThreshold(2, bwtotal); + bool net_stats_visible = gSavedSettings.getBOOL("ShowNetStats"); + + if (net_stats_visible) + { + // Adding Net Stat Meter back in + F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f; + mSGBandwidth->setMin(0.f); + mSGBandwidth->setMax(bwtotal*1.25f); + mSGBandwidth->setThreshold(0, bwtotal*0.75f); + mSGBandwidth->setThreshold(1, bwtotal); + mSGBandwidth->setThreshold(2, bwtotal); + } // Get current UTC time, adjusted for the user's clock // being off. @@ -283,8 +282,6 @@ void LLStatusBar::refresh() S32 x = MENU_RIGHT + MENU_PARCEL_SPACING; S32 y = 0; - bool search_visible = gSavedSettings.getBOOL("ShowSearchBar"); - // reshape menu bar to its content's width if (MENU_RIGHT != gMenuBarView->getRect().getWidth()) { @@ -439,171 +436,8 @@ void LLStatusBar::refresh() x += buttonRect.getWidth(); } - std::string location_name; - if (region) - { - const LLVector3& agent_pos_region = gAgent.getPositionAgent(); - S32 pos_x = lltrunc( agent_pos_region.mV[VX] ); - S32 pos_y = lltrunc( agent_pos_region.mV[VY] ); - S32 pos_z = lltrunc( agent_pos_region.mV[VZ] ); - - // Round the numbers based on the velocity - LLVector3 agent_velocity = gAgent.getVelocity(); - F32 velocity_mag_sq = agent_velocity.magVecSquared(); - - const F32 FLY_CUTOFF = 6.f; // meters/sec - const F32 FLY_CUTOFF_SQ = FLY_CUTOFF * FLY_CUTOFF; - const F32 WALK_CUTOFF = 1.5f; // meters/sec - const F32 WALK_CUTOFF_SQ = WALK_CUTOFF * WALK_CUTOFF; - - if (velocity_mag_sq > FLY_CUTOFF_SQ) - { - pos_x -= pos_x % 4; - pos_y -= pos_y % 4; - } - else if (velocity_mag_sq > WALK_CUTOFF_SQ) - { - pos_x -= pos_x % 2; - pos_y -= pos_y % 2; - } - - mRegionDetails.mTime = mTextTime->getText(); - mRegionDetails.mBalance = mBalance; - mRegionDetails.mAccessString = region->getSimAccessString(); - if (parcel) - { - location_name = region->getName() - + llformat(" %d, %d, %d (%s) - %s", - pos_x, pos_y, pos_z, - region->getSimAccessString().c_str(), - parcel->getName().c_str()); - - // keep these around for the LCD to use - mRegionDetails.mRegionName = region->getName(); - mRegionDetails.mParcelName = parcel->getName(); - mRegionDetails.mX = pos_x; - mRegionDetails.mY = pos_y; - mRegionDetails.mZ = pos_z; - - mRegionDetails.mArea = parcel->getArea(); - mRegionDetails.mForSale = parcel->getForSale(); - mRegionDetails.mTraffic = LLViewerParcelMgr::getInstance()->getDwelling(); - - if (parcel->isPublic()) - { - mRegionDetails.mOwner = LLTrans::getString("Public"); - } - else - { - if (parcel->getIsGroupOwned()) - { - if(!parcel->getGroupID().isNull()) - { - gCacheName->getGroupName(parcel->getGroupID(), mRegionDetails.mOwner); - } - else - { - mRegionDetails.mOwner = LLTrans::getString("GroupOwned"); - } - } - else - { - // Figure out the owner's name - gCacheName->getFullName(parcel->getOwnerID(), mRegionDetails.mOwner); - } - } - } - else - { - location_name = region->getName() - + llformat(" %d, %d, %d (%s)", - pos_x, pos_y, pos_z, - region->getSimAccessString().c_str()); - // keep these around for the LCD to use - mRegionDetails.mRegionName = region->getName(); - mRegionDetails.mParcelName = LLTrans::getString("Unknown"); - - mRegionDetails.mX = pos_x; - mRegionDetails.mY = pos_y; - mRegionDetails.mZ = pos_z; - mRegionDetails.mArea = 0; - mRegionDetails.mForSale = FALSE; - mRegionDetails.mOwner = LLTrans::getString("Unknown"); - mRegionDetails.mTraffic = 0.0f; - } - } - else - { - // no region - location_name = LLTrans::getString("Unknown"); - // keep these around for the LCD to use - mRegionDetails.mRegionName = LLTrans::getString("Unknown"); - mRegionDetails.mParcelName = LLTrans::getString("Unknown"); - mRegionDetails.mAccessString = LLTrans::getString("Unknown"); - mRegionDetails.mX = 0; - mRegionDetails.mY = 0; - mRegionDetails.mZ = 0; - mRegionDetails.mArea = 0; - mRegionDetails.mForSale = FALSE; - mRegionDetails.mOwner = LLTrans::getString("Unknown"); - mRegionDetails.mTraffic = 0.0f; - } - - mTextParcelName->setText(location_name); - - - - // x = right edge - // loop through: stat graphs, search btn, search text editor, money, buy money, clock - // adjust rect - // finally adjust parcel name rect - - S32 new_right = getRect().getWidth(); - if (search_visible) - { - childGetRect("search_btn", r); - //r.translate( new_right - r.mRight, 0); - //childSetRect("search_btn", r); - new_right -= r.getWidth(); - - childGetRect("search_editor", r); - //r.translate( new_right - r.mRight, 0); - //childSetRect("search_editor", r); - new_right -= r.getWidth() + 6; - } - else - { - childGetRect("stat_btn", r); - r.translate( new_right - r.mRight, 0); - childSetRect("stat_btn", r); - new_right -= r.getWidth() + 6; - } - - // Set rects of money, buy money, time - childGetRect("BalanceText", r); - r.translate( new_right - r.mRight, 0); - childSetRect("BalanceText", r); - new_right -= r.getWidth() - 18; - - childGetRect("buycurrency", r); - r.translate( new_right - r.mRight, 0); - childSetRect("buycurrency", r); - new_right -= r.getWidth() + 6; - - childGetRect("TimeText", r); - // mTextTime->getTextPixelWidth(); - r.translate( new_right - r.mRight, 0); - childSetRect("TimeText", r); - // new_right -= r.getWidth() + MENU_PARCEL_SPACING; - - - // Adjust region name and parcel name - x += 8; - - const S32 PARCEL_RIGHT = llmin(mTextTime->getRect().mLeft, mTextParcelName->getTextPixelWidth() + x + 5); - r.set(x+4, getRect().getHeight() - 2, PARCEL_RIGHT, 0); - mTextParcelName->setRect(r); - + bool search_visible = gSavedSettings.getBOOL("ShowSearchBar"); + // Set search bar visibility if (gAgent.getCameraMode() != CAMERA_MODE_MOUSELOOK) @@ -615,16 +449,15 @@ void LLStatusBar::refresh() childSetVisible("menubar_search_bevel_bg", search_visible); } - mSGBandwidth->setVisible(! search_visible); - mSGPacketLoss->setVisible(! search_visible); - childSetEnabled("stat_btn", ! search_visible); + mSGBandwidth->setVisible(net_stats_visible); + mSGPacketLoss->setVisible(net_stats_visible); + childSetEnabled("stat_btn", net_stats_visible); } void LLStatusBar::setVisibleForMouselook(bool visible) { - mTextBalance->setVisible(visible); mTextTime->setVisible(visible); - childSetVisible("buycurrency", visible); + mBtnBuyCurrency->setVisible(visible); childSetVisible("search_editor", visible); childSetVisible("search_btn", visible); childSetVisible("menubar_search_bevel_bg", visible); @@ -648,7 +481,15 @@ void LLStatusBar::setBalance(S32 balance) std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance ); std::string balance_str = "L$"; balance_str += money_str; - mTextBalance->setText( balance_str ); + mBtnBuyCurrency->setLabel( balance_str ); + + // Resize the balance button so that the label fits it, and the button expands to the left. + // *TODO: LLButton should have an option where to expand. + { + S32 saved_right = mBtnBuyCurrency->getRect().mRight; + mBtnBuyCurrency->autoResize(); + mBtnBuyCurrency->translate(saved_right - mBtnBuyCurrency->getRect().mRight, 0); + } if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold"))) { @@ -752,18 +593,6 @@ S32 LLStatusBar::getSquareMetersLeft() const return mSquareMetersCredit - mSquareMetersCommitted; } -static void onClickParcelInfo(void* data) -{ - LLViewerParcelMgr::getInstance()->selectParcelAt(gAgent.getPositionGlobal()); - - LLFloaterLand::showInstance(); -} - -static void onClickBalance(void* data) -{ - onClickBuyCurrency(data); -} - static void onClickBuyCurrency(void* data) { LLFloaterBuyCurrency::buyCurrency(); @@ -903,7 +732,7 @@ void LLStatusBar::onClickSearch(void* data) // static void LLStatusBar::onClickStatGraph(void* data) { - LLFloaterLagMeter::showInstance(); + LLFloaterReg::showInstance("lagmeter"); } BOOL can_afford_transaction(S32 cost) |