summaryrefslogtreecommitdiff
path: root/indra/newview/llstatusbar.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-06-21 08:04:56 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-06-21 08:04:56 +0000
commit9ec432034dc3c45d7ce763eb02dae4cc7f6b8da8 (patch)
tree4a505c1e0919af52800b3ffb3eaf135e7d6f9ce6 /indra/newview/llstatusbar.cpp
parent351ebe9fcb76f3b99c2957004bb8493a904869ee (diff)
merge -r 122421-124917 viewer-2.0.0-2 -> viewer-2.0.0-3
ignore-dead-branch
Diffstat (limited to 'indra/newview/llstatusbar.cpp')
-rw-r--r--indra/newview/llstatusbar.cpp336
1 files changed, 71 insertions, 265 deletions
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index f36d12d638..981a843d94 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -53,6 +53,7 @@
#include "llmenugl.h"
#include "llnotify.h"
#include "llimview.h"
+#include "llsd.h"
#include "lltextbox.h"
#include "llui.h"
#include "llviewerparceloverlay.h"
@@ -60,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"
@@ -73,9 +74,10 @@
#include "lltoolmgr.h"
#include "llfocusmgr.h"
#include "llappviewer.h"
-
+#include "lltrans.h"
// library includes
#include "imageids.h"
+#include "llfloaterreg.h"
#include "llfontgl.h"
#include "llrect.h"
#include "llerror.h"
@@ -91,7 +93,7 @@
// Globals
//
LLStatusBar *gStatusBar = NULL;
-S32 STATUS_BAR_HEIGHT = 0;
+S32 STATUS_BAR_HEIGHT = 26;
extern S32 MENU_BAR_HEIGHT;
@@ -107,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*);
@@ -123,13 +123,15 @@ std::vector<std::string> LLStatusBar::sDays;
std::vector<std::string> LLStatusBar::sMonths;
const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000;
-LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect)
-: LLPanel(name, LLRect(), FALSE), // not mouse opaque
-mBalance(0),
-mHealth(100),
-mSquareMetersCredit(0),
-mSquareMetersCommitted(0)
+LLStatusBar::LLStatusBar(const LLRect& rect)
+: LLPanel(),
+ mBalance(0),
+ mHealth(100),
+ mSquareMetersCredit(0),
+ mSquareMetersCommitted(0)
{
+ setRect(rect);
+
// status bar can possible overlay menus?
setMouseOpaque(FALSE);
setIsChrome(TRUE);
@@ -149,17 +151,16 @@ mSquareMetersCommitted(0)
// 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 );
@@ -172,33 +173,33 @@ mSquareMetersCommitted(0)
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;
LLRect r;
r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
- mSGBandwidth = new LLStatGraph("BandwidthGraph", r);
- mSGBandwidth->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+ LLStatGraph::Params sgp;
+ sgp.name("BandwidthGraph");
+ sgp.rect(r);
+ sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+ sgp.mouse_opaque(false);
+ mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
mSGBandwidth->setStat(&LLViewerStats::getInstance()->mKBitStat);
- std::string text = childGetText("bandwidth_tooltip") + " ";
- LLUIString bandwidth_tooltip = text; // get the text from XML until this widget is XML driven
- mSGBandwidth->setLabel(bandwidth_tooltip.getString());
mSGBandwidth->setUnits("Kbps");
mSGBandwidth->setPrecision(0);
- mSGBandwidth->setMouseOpaque(FALSE);
addChild(mSGBandwidth);
x -= SIM_STAT_WIDTH + 2;
r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
- mSGPacketLoss = new LLStatGraph("PacketLossPercent", r);
- mSGPacketLoss->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+ //these don't seem to like being reused
+ LLStatGraph::Params pgp;
+ pgp.name("PacketLossPercent");
+ pgp.rect(r);
+ pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+ pgp.mouse_opaque(false);
+
+ mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
mSGPacketLoss->setStat(&LLViewerStats::getInstance()->mPacketsLostPercentStat);
- text = childGetText("packet_loss_tooltip") + " ";
- LLUIString packet_loss_tooltip = text; // get the text from XML until this widget is XML driven
- mSGPacketLoss->setLabel(packet_loss_tooltip.getString());
mSGPacketLoss->setUnits("%");
mSGPacketLoss->setMin(0.f);
mSGPacketLoss->setMax(5.f);
@@ -206,7 +207,6 @@ mSquareMetersCommitted(0)
mSGPacketLoss->setThreshold(1, 1.f);
mSGPacketLoss->setThreshold(2, 3.f);
mSGPacketLoss->setPrecision(1);
- mSGPacketLoss->setMouseOpaque(FALSE);
mSGPacketLoss->mPerSec = FALSE;
addChild(mSGPacketLoss);
@@ -236,9 +236,10 @@ void LLStatusBar::draw()
if (isBackgroundVisible())
{
+ static LLUICachedControl<S32> drop_shadow_floater ("DropShadowFloater", 0);
+ static LLUICachedControl<LLColor4> color_drop_shadow ("ColorDropShadow");
gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
- LLUI::sColorsGroup->getColor("ColorDropShadow"),
- LLUI::sConfigGroup->getS32("DropShadowFloater") );
+ color_drop_shadow, drop_shadow_floater );
}
LLPanel::draw();
}
@@ -247,66 +248,40 @@ 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);
-
- // *TODO: Localize / translate time
-
+ 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.
time_t utc_time;
utc_time = time_corrected();
- // There's only one internal tm buffer.
- struct tm* internal_time;
-
- // Convert to Pacific, based on server's opinion of whether
- // it's daylight savings time there.
- internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
-
- S32 hour = internal_time->tm_hour;
- S32 min = internal_time->tm_min;
-
- std::string am_pm = "AM";
- if (hour > 11)
- {
- hour -= 12;
- am_pm = "PM";
- }
-
- std::string tz = "PST";
- if (gPacificDaylightTime)
- {
- tz = "PDT";
- }
- // Zero hour is 12 AM
- if (hour == 0) hour = 12;
- std::ostringstream t;
- t << std::setfill(' ') << std::setw(2) << hour << ":"
- << std::setfill('0') << std::setw(2) << min
- << " " << am_pm << " " << tz;
- mTextTime->setText(t.str());
+ std::string timeStr = getString("time");
+ LLSD substitution;
+ substitution["datetime"] = (S32) utc_time;
+ LLStringUtil::format (timeStr, substitution);
+ mTextTime->setText(timeStr);
- // Year starts at 1900, set the tooltip to have the date
- std::ostringstream date;
- date << sDays[internal_time->tm_wday] << ", "
- << std::setfill('0') << std::setw(2) << internal_time->tm_mday << " "
- << sMonths[internal_time->tm_mon] << " "
- << internal_time->tm_year + 1900;
- mTextTime->setToolTip(date.str());
+ // 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;
- bool search_visible = gSavedSettings.getBOOL("ShowSearchBar");
-
// reshape menu bar to its content's width
if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
{
@@ -461,172 +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();
- mRegionDetails.mPing = region->getNetDetailsForLCD();
- 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 = "Public";
- }
- else
- {
- if (parcel->getIsGroupOwned())
- {
- if(!parcel->getGroupID().isNull())
- {
- gCacheName->getGroupName(parcel->getGroupID(), mRegionDetails.mOwner);
- }
- else
- {
- mRegionDetails.mOwner = "Group Owned";
- }
- }
- 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 = "Unknown";
-
- mRegionDetails.mX = pos_x;
- mRegionDetails.mY = pos_y;
- mRegionDetails.mZ = pos_z;
- mRegionDetails.mArea = 0;
- mRegionDetails.mForSale = FALSE;
- mRegionDetails.mOwner = "Unknown";
- mRegionDetails.mTraffic = 0.0f;
- }
- }
- else
- {
- // no region
- location_name = "(Unknown)";
- // keep these around for the LCD to use
- mRegionDetails.mRegionName = "Unknown";
- mRegionDetails.mParcelName = "Unknown";
- mRegionDetails.mAccessString = "Unknown";
- mRegionDetails.mX = 0;
- mRegionDetails.mY = 0;
- mRegionDetails.mZ = 0;
- mRegionDetails.mArea = 0;
- mRegionDetails.mForSale = FALSE;
- mRegionDetails.mOwner = "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)
@@ -638,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);
@@ -671,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")))
{
@@ -775,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();
@@ -920,7 +726,7 @@ void LLStatusBar::onClickSearch(void* data)
{
LLStatusBar* self = (LLStatusBar*)data;
std::string search_text = self->childGetText("search_editor");
- LLFloaterDirectory::showFindAll(search_text);
+ LLFloaterReg::showInstance("search", LLSD().insert("panel", "all").insert("id", LLSD(search_text)));
}
// static