llstatusbar.cpp

Go to the documentation of this file.
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"         // to spawn search
00052 #include "llfloaterland.h"
00053 #include "llfloaterregioninfo.h"
00054 #include "llfloaterscriptdebug.h"
00055 #include "llhudicon.h"
00056 #include "llinventoryview.h"
00057 #include "llkeyboard.h"
00058 #include "lllineeditor.h"
00059 #include "llmenugl.h"
00060 #include "llnotify.h"
00061 #include "llimview.h"
00062 #include "lltextbox.h"
00063 #include "llui.h"
00064 #include "llviewerparceloverlay.h"
00065 #include "llviewerregion.h"
00066 #include "llviewerstats.h"
00067 #include "llviewerwindow.h"
00068 #include "llframetimer.h"
00069 #include "llvoavatar.h"
00070 #include "llresmgr.h"
00071 #include "llworld.h"
00072 #include "llstatgraph.h"
00073 #include "llviewermenu.h"       // for gMenuBarView
00074 #include "llviewerparcelmgr.h"
00075 #include "llviewerthrottle.h"
00076 #include "llvieweruictrlfactory.h"
00077 #include "llvoiceclient.h"      // for gVoiceClient
00078 
00079 #include "lltoolmgr.h"
00080 #include "llfocusmgr.h"
00081 #include "viewer.h"
00082 
00083 //#include "llfirstuse.h"
00084 
00085 //
00086 // Globals
00087 //
00088 LLStatusBar *gStatusBar = NULL;
00089 S32 STATUS_BAR_HEIGHT = 0;
00090 extern S32 MENU_BAR_HEIGHT;
00091 
00092 
00093 // TODO: these values ought to be in the XML too
00094 const S32 MENU_PARCEL_SPACING = 1;      // Distance from right of menu item to parcel information
00095 const S32 SIM_STAT_WIDTH = 8;
00096 const F32 SIM_WARN_FRACTION = 0.75f;
00097 const F32 SIM_FULL_FRACTION = 0.98f;
00098 const LLColor4 SIM_OK_COLOR(0.f, 1.f, 0.f, 1.f);
00099 const LLColor4 SIM_WARN_COLOR(1.f, 1.f, 0.f, 1.f);
00100 const LLColor4 SIM_FULL_COLOR(1.f, 0.f, 0.f, 1.f);
00101 const F32 ICON_TIMER_EXPIRY             = 3.f; // How long the balance and health icons should flash after a change.
00102 const F32 ICON_FLASH_FREQUENCY  = 2.f;
00103 const S32 GRAPHIC_FUDGE = 4;
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),         // not mouse opaque
00124         mBalance(0),
00125         mHealth(100),
00126         mSquareMetersCredit(0),
00127         mSquareMetersCommitted(0)
00128 {
00129         // status bar can possible overlay menus?
00130         mMouseOpaque = FALSE;
00131         setIsChrome(TRUE);
00132 
00133         // size of day of the weeks and year
00134         sDays.reserve(7);
00135         sMonths.reserve(12);
00136 
00137         mBalanceTimer = new LLFrameTimer();
00138         mHealthTimer = new LLFrameTimer();
00139 
00140         gUICtrlFactory->buildPanel(this,"panel_status_bar.xml");
00141 
00142         // status bar can never get a tab
00143         setFocusRoot(FALSE);
00144 
00145         // build date necessary data (must do after panel built)
00146         setupDate();
00147 
00148         mTextParcelName = LLUICtrlFactory::getTextBoxByName( this, "ParcelNameText" );
00149         mTextBalance = LLUICtrlFactory::getTextBoxByName( this, "BalanceText" );
00150 
00151         mTextHealth = LLUICtrlFactory::getTextBoxByName( this, "HealthText" );
00152         mTextTime = LLUICtrlFactory::getTextBoxByName( this, "TimeText" );
00153         
00154         childSetAction("scriptout", onClickScriptDebug, this);
00155         childSetAction("health", onClickHealth, this);
00156         childSetAction("fly", onClickFly, this);
00157         childSetAction("buyland", onClickBuyLand, this );
00158         childSetAction("buycurrency", onClickBuyCurrency, this );
00159         childSetAction("build", onClickBuild, this );
00160         childSetAction("scripts", onClickScripts, this );
00161         childSetAction("restrictpush", onClickPush, this );
00162         childSetAction("status_voice", onClickVoice, this );
00163 
00164         childSetCommitCallback("search_editor", onCommitSearch, this);
00165         childSetAction("search_btn", onClickSearch, this);
00166 
00167         childSetActionTextbox("ParcelNameText", onClickParcelInfo );
00168         childSetActionTextbox("BalanceText", onClickBalance );
00169 }
00170 
00171 LLStatusBar::~LLStatusBar()
00172 {
00173         delete mBalanceTimer;
00174         mBalanceTimer = NULL;
00175 
00176         delete mHealthTimer;
00177         mHealthTimer = NULL;
00178 
00179         // LLView destructor cleans up children
00180 }
00181 
00182 //virtual
00183 EWidgetType LLStatusBar::getWidgetType() const
00184 {
00185         return WIDGET_TYPE_STATUS_BAR;
00186 }
00187 
00188 //virtual
00189 LLString LLStatusBar::getWidgetTag() const
00190 {
00191         return LL_STATUS_BAR_TAG;
00192 }
00193 
00194 //-----------------------------------------------------------------------
00195 // Overrides
00196 //-----------------------------------------------------------------------
00197 
00198 // virtual
00199 void LLStatusBar::draw()
00200 {
00201         refresh();
00202 
00203         if (mBgVisible)
00204         {
00205                 gl_drop_shadow(0, mRect.getHeight(), mRect.getWidth(), 0, 
00206                                 LLUI::sColorsGroup->getColor("ColorDropShadow"), 
00207                                 LLUI::sConfigGroup->getS32("DropShadowFloater") );
00208         }
00209         LLPanel::draw();
00210 }
00211 
00212 
00213 // Per-frame updates of visibility
00214 void LLStatusBar::refresh()
00215 {
00216         // *TODO: Localize / translate time
00217         
00218         // Get current UTC time, adjusted for the user's clock
00219         // being off.
00220         U32 utc_time;
00221         utc_time = time_corrected();
00222 
00223         // There's only one internal tm buffer.
00224         struct tm* internal_time;
00225 
00226         // Convert to Pacific, based on server's opinion of whether
00227         // it's daylight savings time there.
00228         internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
00229 
00230         S32 hour = internal_time->tm_hour;
00231         S32 min  = internal_time->tm_min;
00232 
00233         std::string am_pm = "AM";
00234         if (hour > 11)
00235         {
00236                 hour -= 12;
00237                 am_pm = "PM";
00238         }
00239 
00240         std::string tz = "PST";
00241         if (gPacificDaylightTime)
00242         {
00243                 tz = "PDT";
00244         }
00245         // Zero hour is 12 AM
00246         if (hour == 0) hour = 12;
00247         std::ostringstream t;
00248         t << std::setfill(' ') << std::setw(2) << hour << ":" 
00249           << std::setfill('0') << std::setw(2) << min 
00250           << " " << am_pm << " " << tz;
00251         mTextTime->setText(t.str());
00252 
00253         // Year starts at 1900, set the tooltip to have the date
00254         std::ostringstream date;
00255         date    << sDays[internal_time->tm_wday] << ", "
00256                         << std::setfill('0') << std::setw(2) << internal_time->tm_mday << " "
00257                         << sMonths[internal_time->tm_mon] << " "
00258                         << internal_time->tm_year + 1900;
00259         mTextTime->setToolTip(date.str().c_str());
00260 
00261         LLRect r;
00262         const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
00263         S32 x = MENU_RIGHT + MENU_PARCEL_SPACING;
00264         S32 y = 0;
00265         
00266         // reshape menu bar to its content's width
00267         if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
00268         {
00269                 gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
00270         }
00271 
00272         LLViewerRegion *region = gAgent.getRegion();
00273         LLParcel *parcel = gParcelMgr->getAgentParcel();
00274 
00275         LLRect buttonRect;
00276 
00277         if (LLHUDIcon::iconsNearby())
00278         {
00279                 childGetRect( "scriptout", buttonRect );
00280                 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00281                 childSetRect("scriptout",r);
00282                 childSetVisible("scriptout", true);
00283                 x += buttonRect.getWidth();
00284         }
00285         else
00286         {
00287                 childSetVisible("scriptout", false);
00288         }
00289 
00290         if ((region && region->getAllowDamage()) ||
00291                 (parcel && parcel->getAllowDamage()) )
00292         {
00293                 // set visibility based on flashing
00294                 if( mHealthTimer->hasExpired() )
00295                 {
00296                         childSetVisible("health", true);
00297                 }
00298                 else
00299                 {
00300                         BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
00301                         childSetVisible("health", flash);
00302                 }
00303                 mTextHealth->setVisible(TRUE);
00304 
00305                 // Health
00306                 childGetRect( "health", buttonRect );
00307                 r.setOriginAndSize( x, y-GRAPHIC_FUDGE, buttonRect.getWidth(), buttonRect.getHeight());
00308                 childSetRect("health", r);
00309                 x += buttonRect.getWidth();
00310 
00311                 const S32 health_width = S32( LLFontGL::sSansSerifSmall->getWidth("100%") );
00312                 r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
00313                 mTextHealth->setRect(r);
00314                 x += health_width;
00315         }
00316         else
00317         {
00318                 // invisible if region doesn't allow damage
00319                 childSetVisible("health", false);
00320                 mTextHealth->setVisible(FALSE);
00321         }
00322 
00323         if ((region && region->getBlockFly()) ||
00324                 (parcel && !parcel->getAllowFly()) )
00325         {
00326                 // No Fly Zone
00327                 childGetRect( "fly", buttonRect );
00328                 childSetVisible( "fly", true );
00329                 r.setOriginAndSize( x, y-GRAPHIC_FUDGE, buttonRect.getWidth(), buttonRect.getHeight());
00330                 childSetRect( "fly", r );
00331                 x += buttonRect.getWidth();
00332         }
00333         else
00334         {
00335                 childSetVisible("fly", false);
00336         }
00337 
00338         BOOL no_build = parcel && !parcel->getAllowModify();
00339         childSetVisible("build", no_build);
00340         if (no_build)
00341         {
00342                 childGetRect( "build", buttonRect );
00343                 // No Build Zone
00344                 r.setOriginAndSize( x, y-GRAPHIC_FUDGE, buttonRect.getWidth(), buttonRect.getHeight());
00345                 childSetRect( "build", r );
00346                 x += buttonRect.getWidth();
00347         }
00348 
00349         BOOL no_scripts = FALSE;
00350         if((region
00351                 && ((region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
00352                         || (region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)))
00353            || (parcel && !parcel->getAllowOtherScripts()))
00354         {
00355                 no_scripts = TRUE;
00356         }
00357         childSetVisible("scripts", no_scripts);
00358         if (no_scripts)
00359         {
00360                 // No scripts
00361                 childGetRect( "scripts", buttonRect );
00362                 r.setOriginAndSize( x, y-GRAPHIC_FUDGE, buttonRect.getWidth(), buttonRect.getHeight());
00363                 childSetRect( "scripts", r );
00364                 x += buttonRect.getWidth();
00365         }
00366 
00367         BOOL no_region_push = (region && region->getRestrictPushObject());
00368         BOOL no_push = no_region_push || (parcel && parcel->getRestrictPushObject());
00369         childSetVisible("restrictpush", no_push);
00370         if (no_push)
00371         {
00372                 childGetRect( "restrictpush", buttonRect );
00373                 r.setOriginAndSize( x, y-GRAPHIC_FUDGE, buttonRect.getWidth(), buttonRect.getHeight());
00374                 childSetRect( "restrictpush", r );
00375                 x += buttonRect.getWidth();
00376         }
00377 
00378         BOOL have_voice = gVoiceClient->getAreaVoiceDisabled() ? FALSE : TRUE;
00379         childSetVisible("status_voice", have_voice);
00380         if (have_voice)
00381         {
00382                 childGetRect( "status_voice", buttonRect );
00383                 r.setOriginAndSize( x, y-GRAPHIC_FUDGE, buttonRect.getWidth(), buttonRect.getHeight());
00384                 childSetRect( "status_voice", r );
00385                 x += buttonRect.getWidth();
00386         }
00387 
00388         BOOL canBuyLand = parcel
00389                 && !parcel->isPublic()
00390                 && gParcelMgr->canAgentBuyParcel(parcel, false);
00391         childSetVisible("buyland", canBuyLand);
00392         if (canBuyLand)
00393         {
00394                 childGetRect( "buyland", buttonRect );
00395                 r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
00396                 childSetRect( "buyland", r );
00397                 x += buttonRect.getWidth();
00398         }
00399 
00400         LLString location_name;
00401         if (region)
00402         {
00403                 const LLVector3& agent_pos_region = gAgent.getPositionAgent();
00404                 S32 pos_x = lltrunc( agent_pos_region.mV[VX] );
00405                 S32 pos_y = lltrunc( agent_pos_region.mV[VY] );
00406                 S32 pos_z = lltrunc( agent_pos_region.mV[VZ] );
00407 
00408                 // Round the numbers based on the velocity
00409                 LLVector3 agent_velocity = gAgent.getVelocity();
00410                 F32 velocity_mag_sq = agent_velocity.magVecSquared();
00411 
00412                 const F32 FLY_CUTOFF = 6.f;             // meters/sec
00413                 const F32 FLY_CUTOFF_SQ = FLY_CUTOFF * FLY_CUTOFF;
00414                 const F32 WALK_CUTOFF = 1.5f;   // meters/sec
00415                 const F32 WALK_CUTOFF_SQ = WALK_CUTOFF * WALK_CUTOFF;
00416 
00417                 if (velocity_mag_sq > FLY_CUTOFF_SQ)
00418                 {
00419                         pos_x -= pos_x % 4;
00420                         pos_y -= pos_y % 4;
00421                 }
00422                 else if (velocity_mag_sq > WALK_CUTOFF_SQ)
00423                 {
00424                         pos_x -= pos_x % 2;
00425                         pos_y -= pos_y % 2;
00426                 }
00427 
00428                 mRegionDetails.mTime = mTextTime->getText();
00429                 mRegionDetails.mBalance = mBalance;
00430                 mRegionDetails.mAccesString = (char *)region->getSimAccessString();
00431                 mRegionDetails.mPing = region->getNetDetailsForLCD();
00432                 if (parcel && !parcel->getName().empty())
00433                 {
00434                         location_name = region->getName()
00435                                 + llformat(" %d, %d, %d (%s) - %s", 
00436                                                    pos_x, pos_y, pos_z,
00437                                                    region->getSimAccessString(),
00438                                                    parcel->getName().c_str());
00439 
00440                         // keep these around for the LCD to use
00441                         mRegionDetails.mRegionName = region->getName();
00442                         mRegionDetails.mParcelName = (char *)parcel->getName().c_str();
00443                         mRegionDetails.mX = pos_x;
00444                         mRegionDetails.mY = pos_y;
00445                         mRegionDetails.mZ = pos_z;
00446                         mRegionDetails.mArea = parcel->getArea();
00447                         mRegionDetails.mForSale = parcel->getForSale();
00448                         mRegionDetails.mTraffic = gParcelMgr->getDwelling();
00449                         
00450                         if (parcel->isPublic())
00451                         {
00452                                 snprintf(mRegionDetails.mOwner, MAX_STRING, "Public");
00453                         }
00454                         else
00455                         {
00456                                 if (parcel->getIsGroupOwned())
00457                                 {
00458                                         if(!parcel->getGroupID().isNull())
00459                                         {
00460                                                 gCacheName->getGroupName(parcel->getGroupID(), mRegionDetails.mOwner);
00461                                         }
00462                                         else
00463                                         {
00464                                                 snprintf(mRegionDetails.mOwner, MAX_STRING, "Group Owned");
00465                                         }
00466                                 }
00467                                 else
00468                                 {
00469                                         // Figure out the owner's name
00470                                         char owner_first[MAX_STRING];   /*Flawfinder: ignore*/
00471                                         char owner_last[MAX_STRING];    /*Flawfinder: ignore*/
00472                                         gCacheName->getName(parcel->getOwnerID(), owner_first, owner_last);
00473                                         snprintf(mRegionDetails.mOwner, MAX_STRING, "%s %s", owner_first, owner_last);          /* Flawfinder: ignore */
00474                                 }
00475                         }
00476                 }
00477                 else
00478                 {
00479                         location_name = region->getName()
00480                                 + llformat(" %d, %d, %d (%s)", 
00481                                                    pos_x, pos_y, pos_z,
00482                                                    region->getSimAccessString());
00483                         // keep these around for the LCD to use
00484                         mRegionDetails.mRegionName = region->getName();
00485                         mRegionDetails.mParcelName = "Unknown";
00486                         
00487                         mRegionDetails.mX = pos_x;
00488                         mRegionDetails.mY = pos_y;
00489                         mRegionDetails.mZ = pos_z;
00490                         mRegionDetails.mArea = 0;
00491                         mRegionDetails.mForSale = FALSE;
00492                         snprintf(mRegionDetails.mOwner, MAX_STRING, "Unknown");
00493                         mRegionDetails.mTraffic = 0.0f;
00494                 }
00495         }
00496         else
00497         {
00498                 // no region
00499                 location_name = "(Unknown)";
00500                 // keep these around for the LCD to use
00501                 mRegionDetails.mRegionName = LLString("Unknown");
00502                 mRegionDetails.mParcelName = "Unknown";
00503                 mRegionDetails.mAccesString = "Unknown";
00504                 mRegionDetails.mX = 0;
00505                 mRegionDetails.mY = 0;
00506                 mRegionDetails.mZ = 0;
00507                 mRegionDetails.mArea = 0;
00508                 mRegionDetails.mForSale = FALSE;
00509                 snprintf(mRegionDetails.mOwner, MAX_STRING, "Unknown");
00510                 mRegionDetails.mTraffic = 0.0f;
00511         }
00512         mTextParcelName->setText(location_name);
00513 
00514         // Adjust region name and parcel name
00515         x += 4;
00516 
00517         const S32 PARCEL_RIGHT =  llmin(mTextTime->getRect().mLeft, mTextParcelName->getTextPixelWidth() + x + 5);
00518         r.set(x+4, mRect.getHeight() - 2, PARCEL_RIGHT, 0);
00519         mTextParcelName->setRect(r);
00520 }
00521 
00522 void LLStatusBar::setVisibleForMouselook(bool visible)
00523 {
00524         mTextBalance->setVisible(visible);
00525         mTextTime->setVisible(visible);
00526         childSetVisible("buycurrency", visible);
00527         childSetVisible("search_editor", visible);
00528         childSetVisible("search_btn", visible);
00529         setBackgroundVisible(visible);
00530 }
00531 
00532 void LLStatusBar::debitBalance(S32 debit)
00533 {
00534         setBalance(getBalance() - debit);
00535 }
00536 
00537 void LLStatusBar::creditBalance(S32 credit)
00538 {
00539         setBalance(getBalance() + credit);
00540 }
00541 
00542 void LLStatusBar::setBalance(S32 balance)
00543 {
00544         LLString money_str = gResMgr->getMonetaryString( balance );
00545         LLString balance_str = "L$";
00546         balance_str += money_str;
00547         mTextBalance->setText( balance_str );
00548 
00549         if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
00550         {
00551                 if (mBalance > balance)
00552                         make_ui_sound("UISndMoneyChangeDown");
00553                 else
00554                         make_ui_sound("UISndMoneyChangeUp");
00555         }
00556 
00557         if( balance != mBalance )
00558         {
00559                 mBalanceTimer->reset();
00560                 mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
00561                 mBalance = balance;
00562         }
00563 }
00564 
00565 void LLStatusBar::setHealth(S32 health)
00566 {
00567         //llinfos << "Setting health to: " << buffer << llendl;
00568         mTextHealth->setText(llformat("%d%%", health));
00569 
00570         if( mHealth > health )
00571         {
00572                 if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
00573                 {
00574                         LLVOAvatar *me;
00575 
00576                         if ((me = gAgent.getAvatarObject()))
00577                         {
00578                                 if (me->getSex() == SEX_FEMALE)
00579                                 {
00580                                         make_ui_sound("UISndHealthReductionF");
00581                                 }
00582                                 else
00583                                 {
00584                                         make_ui_sound("UISndHealthReductionM");
00585                                 }
00586                         }
00587                 }
00588 
00589                 mHealthTimer->reset();
00590                 mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
00591         }
00592 
00593         mHealth = health;
00594 }
00595 
00596 S32 LLStatusBar::getBalance() const
00597 {
00598         return mBalance;
00599 }
00600 
00601 
00602 S32 LLStatusBar::getHealth() const
00603 {
00604         return mHealth;
00605 }
00606 
00607 void LLStatusBar::setLandCredit(S32 credit)
00608 {
00609         mSquareMetersCredit = credit;
00610 }
00611 void LLStatusBar::setLandCommitted(S32 committed)
00612 {
00613         mSquareMetersCommitted = committed;
00614 }
00615 
00616 BOOL LLStatusBar::isUserTiered() const
00617 {
00618         return (mSquareMetersCredit > 0);
00619 }
00620 
00621 S32 LLStatusBar::getSquareMetersCredit() const
00622 {
00623         return mSquareMetersCredit;
00624 }
00625 
00626 S32 LLStatusBar::getSquareMetersCommitted() const
00627 {
00628         return mSquareMetersCommitted;
00629 }
00630 
00631 S32 LLStatusBar::getSquareMetersLeft() const
00632 {
00633         return mSquareMetersCredit - mSquareMetersCommitted;
00634 }
00635 
00636 static void onClickParcelInfo(void* data)
00637 {
00638         gParcelMgr->selectParcelAt(gAgent.getPositionGlobal());
00639 
00640         LLFloaterLand::show();
00641 }
00642 
00643 static void onClickBalance(void* data)
00644 {
00645         LLFloaterBuyCurrency::buyCurrency();
00646 }
00647 
00648 static void onClickBuyCurrency(void* data)
00649 {
00650         LLFloaterBuyCurrency::buyCurrency();
00651 }
00652 
00653 static void onClickHealth(void* )
00654 {
00655         LLNotifyBox::showXml("NotSafe");
00656 }
00657 
00658 static void onClickScriptDebug(void*)
00659 {
00660         LLFloaterScriptDebug::show(LLUUID::null);
00661 }
00662 
00663 static void onClickFly(void* )
00664 {
00665         LLNotifyBox::showXml("NoFly");
00666 }
00667 
00668 static void onClickPush(void* )
00669 {
00670         LLNotifyBox::showXml("PushRestricted");
00671 }
00672 
00673 static void onClickVoice(void* )
00674 {
00675         LLNotifyBox::showXml("VoiceAvailablity");
00676         //LLFirstUse::useVoice();
00677 }
00678 
00679 static void onClickBuild(void*)
00680 {
00681         LLNotifyBox::showXml("NoBuild");
00682 }
00683 
00684 static void onClickScripts(void*)
00685 {
00686         LLViewerRegion* region = gAgent.getRegion();
00687         if(region && region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)
00688         {
00689                 LLNotifyBox::showXml("ScriptsStopped");
00690         }
00691         else if(region && region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
00692         {
00693                 LLNotifyBox::showXml("ScriptsNotRunning");
00694         }
00695         else
00696         {
00697                 LLNotifyBox::showXml("NoOutsideScripts");
00698         }
00699 }
00700 
00701 static void onClickBuyLand(void*)
00702 {
00703         gParcelMgr->selectParcelAt(gAgent.getPositionGlobal());
00704         gParcelMgr->startBuyLand();
00705 }
00706 
00707 // sets the static variables necessary for the date
00708 void LLStatusBar::setupDate()
00709 {
00710         // fill the day array with what's in the xui
00711         LLString day_list = childGetText("StatBarDaysOfWeek");
00712         size_t length = day_list.size();
00713         
00714         // quick input check
00715         if(length < MAX_DATE_STRING_LENGTH)
00716         {
00717                 // tokenize it and put it in the array
00718                 LLString cur_word;
00719                 for(size_t i = 0; i < length; ++i)
00720                 {
00721                         if(day_list[i] == ':')
00722                         {
00723                                 sDays.push_back(cur_word);
00724                                 cur_word.clear();
00725                         }
00726                         else
00727                         {
00728                                 cur_word.append(1, day_list.c_str()[i]);
00729                         }
00730                 }
00731                 sDays.push_back(cur_word);
00732         }
00733         
00734         // fill the day array with what's in the xui    
00735         LLString month_list = childGetText( "StatBarMonthsOfYear" );
00736         length = month_list.size();
00737         
00738         // quick input check
00739         if(length < MAX_DATE_STRING_LENGTH)
00740         {
00741                 // tokenize it and put it in the array
00742                 LLString cur_word;
00743                 for(size_t i = 0; i < length; ++i)
00744                 {
00745                         if(month_list[i] == ':')
00746                         {
00747                                 sMonths.push_back(cur_word);
00748                                 cur_word.clear();
00749                         }
00750                         else
00751                         {
00752                                 cur_word.append(1, month_list.c_str()[i]);
00753                         }
00754                 }
00755                 sMonths.push_back(cur_word);
00756         }
00757         
00758         // make sure we have at least 7 days and 12 months
00759         if(sDays.size() < 7)
00760         {
00761                 sDays.resize(7);
00762         }
00763         
00764         if(sMonths.size() < 12)
00765         {
00766                 sMonths.resize(12);
00767         }
00768 }
00769 
00770 // static
00771 void LLStatusBar::onCommitSearch(LLUICtrl*, void* data)
00772 {
00773         // committing is the same as clicking "search"
00774         onClickSearch(data);
00775 }
00776 
00777 // static
00778 void LLStatusBar::onClickSearch(void* data)
00779 {
00780         LLStatusBar* self = (LLStatusBar*)data;
00781         LLString search_text = self->childGetText("search_editor");
00782         LLFloaterDirectory::showFindAll(search_text);
00783 }
00784 
00785 BOOL can_afford_transaction(S32 cost)
00786 {
00787         return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
00788 }

Generated on Thu Jul 1 06:09:13 2010 for Second Life Viewer by  doxygen 1.4.7