//this bit should be rewritten entirely
void DOFloaterHex::show(LLUUID item_id, BOOL vfs, LLAssetType::EType asset_type)
{
	if(!vfs)
	{
		LLInventoryItem* item = (LLInventoryItem*)gInventory.getItem(item_id);
		if(item)
		{
			S32 left, top;
			gFloaterView->getNewFloaterPosition(&left, &top);
			LLRect rect = gSavedSettings.getRect("FloaterHexRect");
			rect.translate(left - rect.mLeft, top - rect.mTop);

			DOFloaterHex* floaterp = new DOFloaterHex(item_id);
			floaterp->setRect(rect);

			gFloaterView->adjustToFitScreen(floaterp, FALSE);
		}
	} else if (item_id.notNull() && asset_type != LLAssetType::AT_NONE) {
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);
		LLRect rect = gSavedSettings.getRect("FloaterHexRect");
		rect.translate(left - rect.mLeft, top - rect.mTop);
		DOFloaterHex* floaterp = new DOFloaterHex(item_id, true, asset_type);
		floaterp->setRect(rect);

		llinfos << "Asset ID: " << item_id.asString() << llendl;

		gFloaterView->adjustToFitScreen(floaterp, FALSE);
	}
}
void LLFloaterLagMeter::updateControls(bool shrink)
{
//	LLFloaterLagMeter * self = (LLFloaterLagMeter*)data;

	LLButton * button = getChild<LLButton>("minimize");
	S32 delta_width = mMaxWidth -mMinWidth;
	LLRect r = getRect();

	if(!shrink)
	{
		setTitle(getString("max_title_msg", mStringArgs) );
		// make left edge appear to expand
		r.translate(-delta_width, 0);
		setRect(r);
		reshape(mMaxWidth, getRect().getHeight());
		
		childSetText("client", getString("client_text_msg", mStringArgs) + ":");
		childSetText("network", getString("network_text_msg",mStringArgs) + ":");
		childSetText("server", getString("server_text_msg", mStringArgs) + ":");

		// usually "<<"
		button->setLabel( getString("smaller_label", mStringArgs) );
	}
	else
	{
		setTitle( getString("min_title_msg", mStringArgs) );
		// make left edge appear to collapse
		r.translate(delta_width, 0);
		setRect(r);
		reshape(mMinWidth, getRect().getHeight());
		
		childSetText("client", getString("client_text_msg", mStringArgs) );
		childSetText("network",getString("network_text_msg",mStringArgs) );
		childSetText("server", getString("server_text_msg", mStringArgs) );

		// usually ">>"
		button->setLabel( getString("bigger_label", mStringArgs) );
	}
	// Don't put keyboard focus on the button
	button->setFocus(FALSE);

//	self->mClientText->setVisible(self->mShrunk);
//	self->mClientCause->setVisible(self->mShrunk);
//	self->childSetVisible("client_help", self->mShrunk);

//	self->mNetworkText->setVisible(self->mShrunk);
//	self->mNetworkCause->setVisible(self->mShrunk);
//	self->childSetVisible("network_help", self->mShrunk);

//	self->mServerText->setVisible(self->mShrunk);
//	self->mServerCause->setVisible(self->mShrunk);
//	self->childSetVisible("server_help", self->mShrunk);

//	self->mShrunk = !self->mShrunk;
}
Example #3
0
void LLViewerTextEditor::openEmbeddedTexture( LLInventoryItem* item )
{
	// See if we can bring an existing preview to the front
	// *NOTE:  Just for embedded Texture , we should use getAssetUUID(), 
	// not getUUID(), because LLPreviewTexture pass in AssetUUID into 
	// LLPreview constructor ItemUUID parameter.

	if( !LLPreview::show( item->getAssetUUID() ) )
	{
		// There isn't one, so make a new preview
		if(item)
		{
			S32 left, top;
			gFloaterView->getNewFloaterPosition(&left, &top);
			LLRect rect = gSavedSettings.getRect("PreviewTextureRect");
			rect.translate( left - rect.mLeft, top - rect.mTop );

			LLPreviewTexture* preview = new LLPreviewTexture("preview texture",
				rect,
				item->getName(),
				item->getAssetUUID(),
				TRUE);
			preview->setAuxItem( item );
			preview->setNotecardInfo(mNotecardInventoryID, mObjectID);
		}
	}
}
void LLViewerTextEditor::openEmbeddedTexture( LLInventoryItem* item, llwchar wc )
{
// [RLVa:KB] - Checked: 2009-11-11 (RLVa-1.1.0a) | Modified: RLVa-1.1.0a
	if (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE))
	{
		RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_TEXTURE);
		return;
	}
// [/RLVa:KB]

	// See if we can bring an existing preview to the front
	// *NOTE:  Just for embedded Texture , we should use getAssetUUID(), 
	// not getUUID(), because LLPreviewTexture pass in AssetUUID into 
	// LLPreview constructor ItemUUID parameter.

	if( !LLPreview::show( item->getAssetUUID() ) )
	{
		// There isn't one, so make a new preview
		if(item)
		{
			S32 left, top;
			gFloaterView->getNewFloaterPosition(&left, &top);
			LLRect rect = gSavedSettings.getRect("PreviewTextureRect");
			rect.translate( left - rect.mLeft, top - rect.mTop );

			LLPreviewTexture* preview = new LLPreviewTexture("preview texture",
				rect,
				item->getName(),
				item->getAssetUUID(),
				TRUE);
			preview->setAuxItem( item );
			preview->setNotecardInfo(mNotecardInventoryID, mObjectID);
		}
	}
}
Example #5
0
// static
void LLPanelContents::onClickNewScript(void *userdata)
{
	const BOOL children_ok = TRUE;
	LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
	if(object)
	{
		LLPermissions perm;
		perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
		perm.initMasks(
			PERM_ALL,
			PERM_ALL,
			PERM_NONE,
			PERM_NONE,
			PERM_MOVE | PERM_TRANSFER);
		std::string desc;
		LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc);
		LLPointer<LLViewerInventoryItem> new_item =
			new LLViewerInventoryItem(
				LLUUID::null,
				LLUUID::null,
				perm,
				LLUUID::null,
				LLAssetType::AT_LSL_TEXT,
				LLInventoryType::IT_LSL,
				std::string("New Script"),
				desc,
				LLSaleInfo::DEFAULT,
				LLViewerInventoryItem::II_FLAGS_NONE,
				time_corrected());
		object->saveScript(new_item, TRUE, true);

		// *NOTE: In order to resolve SL-22177, we needed to create
		// the script first, and then you have to click it in
		// inventory to edit it.
		// *TODO: The script creation should round-trip back to the
		// viewer so the viewer can auto-open the script and start
		// editing ASAP.
#if 0
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);
		LLRect rect = gSavedSettings.getRect("PreviewScriptRect");
		rect.translate( left - rect.mLeft, top - rect.mTop );

		LLLiveLSLEditor* editor;
		editor = new LLLiveLSLEditor("script ed",
									   rect,
									   "Script: New Script",
									   object->mID,
									   LLUUID::null);
		editor->open();	/*Flawfinder: ignore*/

		// keep onscreen
		gFloaterView->adjustToFitScreen(editor, FALSE);
#endif
	}
}
Example #6
0
// static
LLFloaterBulkPermission* LLFloaterBulkPermission::create()
{
	S32 left, top;
	gFloaterView->getNewFloaterPosition(&left, &top);
	LLRect rect = gSavedSettings.getRect("CompileOutputRect");
	rect.translate(left - rect.mLeft, top - rect.mTop);
	LLFloaterBulkPermission* new_queue = new LLFloaterBulkPermission("queue",rect,"Setting Bulk permissions","Results");
	new_queue->open();	 /*Flawfinder: ignore*/
	return new_queue;
}
Example #7
0
// static
LLFloaterNotRunQueue* LLFloaterNotRunQueue::create()
{
	S32 left, top;
	gFloaterView->getNewFloaterPosition(&left, &top);
	LLRect rect = gSavedSettings.getRect("CompileOutputRect");
	rect.translate(left - rect.mLeft, top - rect.mTop);
	LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue", rect);
	new_queue->open();	 /*Flawfinder: ignore*/
	return new_queue;
}
Example #8
0
void LLFloaterKeyTool::show(LLUUID id)
{
	S32 left, top;
	gFloaterView->getNewFloaterPosition(&left, &top);
	LLRect rect = gSavedSettings.getRect("FloaterKeyToolRect");
	rect.translate(left - rect.mLeft, top - rect.mTop);
	LLFloaterKeyTool* floaterp = new LLFloaterKeyTool(id);
	floaterp->setRect(rect);
	gFloaterView->adjustToFitScreen(floaterp, FALSE);
}
Example #9
0
// static
LLFloaterResetQueue* LLFloaterResetQueue::create()
{
	S32 left, top;
	gFloaterView->getNewFloaterPosition(&left, &top);
	LLRect rect = gSavedSettings.getRect("CompileOutputRect");
	rect.translate(left - rect.mLeft, top - rect.mTop);
	LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue", rect);
	gFloaterView->addChild(new_queue);
	new_queue->open();
	return new_queue;
}
Example #10
0
// static
LLFloaterCompileQueue* LLFloaterCompileQueue::create(BOOL mono)
{
	S32 left, top;
	gFloaterView->getNewFloaterPosition(&left, &top);
	LLRect rect = gSavedSettings.getRect("CompileOutputRect");
	rect.translate(left - rect.mLeft, top - rect.mTop);
	LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", rect);
	
	class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier
	{
	public:
	
		LLCompileFloaterUploadQueueSupplier(const LLUUID& queue_id) :
			mQueueId(queue_id)
		{
		}
		
		virtual LLAssetUploadQueue* get() const 
		{
			LLFloaterCompileQueue* queue = 
				(LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId);
			
			if(NULL == queue)
			{
				return NULL;
			}
			
			return queue->mUploadQueue;
		}

		virtual void log(std::string message) const
		{
			LLFloaterCompileQueue* queue = 
				(LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId);

			if(NULL == queue)
			{
				return;
			}

			LLScrollListCtrl* list = queue->getChild<LLScrollListCtrl>("queue output");
			list->addCommentText(message.c_str());
		}
		
	private:
		LLUUID mQueueId;
	};
																 															 
	new_queue->mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(new_queue->getID()));															 
	new_queue->mMono = mono;
	new_queue->open();
	return new_queue;
}
	// override
	void fire(const LLUUID& inv_item)
	{
		if(!mTextEditor)
		{
			// The parent text editor may have vanished by now. 
            // In that case just quit.
			return;
		}

		LLInventoryItem* item = gInventory.getItem(inv_item);
		if(!item)
		{
			LL_WARNS() << "Item add reported, but not found in inventory!: " << inv_item << LL_ENDL;
		}
		else
		{
// [RLVa:KB] - Checked: 2009-11-11 (RLVa-1.1.0a) | Modified: RLVa-1.1.0a
			if (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE))
			{
				RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_NOTECARD);
				return;
			}
// [/RLVa:KB]

			// See if we can bring an existing preview to the front
			if(!LLPreview::show(item->getUUID(), true))
			{
				if (gSavedSettings.getBOOL("ShowNewInventory")) // Singu Note: ShowNewInventory is true, not false, when they want a preview
				{
					// There isn't one, so make a new preview
					S32 left, top;
					gFloaterView->getNewFloaterPosition(&left, &top);
					LLRect rect = gSavedSettings.getRect("NotecardEditorRect");
					rect.translate(left - rect.mLeft, top - rect.mTop);
					LLPreviewNotecard* preview;
					preview = new LLPreviewNotecard("preview notecard", 
													rect, 
													std::string("Embedded Note: ") + item->getName(),
													item->getUUID(), 
													LLUUID::null, 
													item->getAssetUUID(),
													true, 
													(LLViewerInventoryItem*)item);
					preview->setSourceID(LLUUID::null);
					preview->setFocus(TRUE);

					// Force to be entirely onscreen.
					gFloaterView->adjustToFitScreen(preview, FALSE);
				}
			}
		}
	}
Example #12
0
// static
LLFloaterCompileQueue* LLFloaterCompileQueue::create(BOOL mono)
{
	S32 left, top;
	gFloaterView->getNewFloaterPosition(&left, &top);
	LLRect rect = gSavedSettings.getRect("CompileOutputRect");
	rect.translate(left - rect.mLeft, top - rect.mTop);
	LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", rect);

	new_queue->mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(new_queue->getID()));
	new_queue->mMono = mono;
	new_queue->open();
	return new_queue;
}
// static
void HGFloaterTextEditor::show(LLUUID item_id)
{
	LLInventoryItem* item = (LLInventoryItem*)gInventory.getItem(item_id);
	if(item)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);
		LLRect rect = gSavedSettings.getRect("FloaterAssetTextEditorRect");
		rect.translate(left - rect.mLeft, top - rect.mTop);
		HGFloaterTextEditor* floaterp = new HGFloaterTextEditor(item);
		floaterp->setRect(rect);
		gFloaterView->adjustToFitScreen(floaterp, FALSE);
	}
}
Example #14
0
void LLTextureCtrl::showPicker(BOOL take_focus)
{
	LLFloater* floaterp = mFloaterHandle.get();

	// Show the dialog
	if( floaterp )
	{
		floaterp->open( );		/* Flawfinder: ignore */
	}
	else
	{
		if( !mLastFloaterLeftTop.mX && !mLastFloaterLeftTop.mY )
		{
			gFloaterView->getNewFloaterPosition(&mLastFloaterLeftTop.mX, &mLastFloaterLeftTop.mY);
		}
		LLRect rect = gSavedSettings.getRect("TexturePickerRect");
		rect.translate( mLastFloaterLeftTop.mX - rect.mLeft, mLastFloaterLeftTop.mY - rect.mTop );

		floaterp = new LLFloaterTexturePicker(
			this,
			rect,
			mLabel,
			mImmediateFilterPermMask,
			mDnDFilterPermMask,
			mNonImmediateFilterPermMask,
			mCanApplyImmediately,
			mFallbackImageName);

		mFloaterHandle = floaterp->getHandle();

		LLFloaterTexturePicker* texture_floaterp = dynamic_cast<LLFloaterTexturePicker*>(floaterp);
		if (texture_floaterp && mOnTextureSelectedCallback)
		{
			texture_floaterp->setTextureSelectedCallback(mOnTextureSelectedCallback);
		}

		gFloaterView->getParentFloater(this)->addDependentFloater(floaterp);
		floaterp->open();		/* Flawfinder: ignore */
	}

	if (take_focus)
	{
		floaterp->setFocus(TRUE);
	}
}
Example #15
0
	// override
	void fire(const LLUUID& inv_item)
	{
		if(!mTextEditor)
		{
			// The parent text editor may have vanished by now. 
            // In that case just quit.
			return;
		}

		LLInventoryItem* item = gInventory.getItem(inv_item);
		if(!item)
		{
			llwarns << "Item add reported, but not found in inventory!: " << inv_item << llendl;
		}
		else
		{
			// See if we can bring an existing preview to the front
			if(!LLPreview::show(item->getUUID(), true))
			{
				if(!gSavedSettings.getBOOL("ShowNewInventory"))
				{
					// There isn't one, so make a new preview
					S32 left, top;
					gFloaterView->getNewFloaterPosition(&left, &top);
					LLRect rect = gSavedSettings.getRect("NotecardEditorRect");
					rect.translate(left - rect.mLeft, top - rect.mTop);
					LLPreviewNotecard* preview;
					preview = new LLPreviewNotecard("preview notecard", 
													rect, 
													std::string("Embedded Note: ") + item->getName(),
													item->getUUID(), 
													LLUUID::null, 
													item->getAssetUUID(),
													true, 
													(LLViewerInventoryItem*)item);
					preview->setSourceID(LLUUID::null);
					preview->setFocus(TRUE);

					// Force to be entirely onscreen.
					gFloaterView->adjustToFitScreen(preview, FALSE);
				}
			}
		}
	}
void show_item_profile(const LLUUID& item_uuid)
{
	LLUUID linked_uuid = gInventory.getLinkedItemID(item_uuid);
	if(!LLFloaterProperties::show(linked_uuid, LLUUID::null))
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);
		LLRect rect = gSavedSettings.getRect("PropertiesRect");
		rect.translate( left - rect.mLeft, top - rect.mTop );
		LLFloaterProperties* floater;
		floater = new LLFloaterProperties("item properties",
										rect,
										"Inventory Item Properties",
										linked_uuid,
										LLUUID::null);
		// keep onscreen
		gFloaterView->adjustToFitScreen(floater, FALSE);
	}
}
//static
LLRect LLFloaterReg::getFloaterRect(const std::string& name)
{
	LLRect rect;
	const std::string& groupname = sGroupMap[name];
	if (!groupname.empty())
	{
		instance_list_t& list = sInstanceMap[groupname];
		if (!list.empty())
		{
			static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16);
			LLFloater* last_floater = list.back();
			if (last_floater->getHost())
			{
				rect = last_floater->getHost()->getRect();
			}
			else
			{
				rect = last_floater->getRect();
			}
			rect.translate(floater_offset, -floater_offset);
		}
	}
	return rect;
}
Example #18
0
// static
void LLPanelContents::onClickNewScript(void *userdata)
{
	const BOOL children_ok = TRUE;
	LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
	if(object)
	{
// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a
		if (rlv_handler_t::isEnabled())	// Fallback code [see LLPanelContents::getState()]
		{
			if (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit()))
			{
				return;					// Disallow creating new scripts in a locked attachment
			}
			else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) )
			{
				LLVOAvatar* pAvatar = gAgent.getAvatarObject();
				if ( (pAvatar) && (pAvatar->mIsSitting) && (pAvatar->getRoot() == object->getRootEdit()) )
					return;				// .. or in a linkset the avie is sitting on under @unsit=n/@sittp=n
			}
		}
// [/RLVa:KB]

		LLPermissions perm;
		perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
		perm.initMasks(
			PERM_ALL,
			PERM_ALL,
			PERM_NONE,
			PERM_NONE,
			PERM_MOVE | PERM_TRANSFER);
		std::string desc;
		LLViewerAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc);
		LLPointer<LLViewerInventoryItem> new_item =
			new LLViewerInventoryItem(
				LLUUID::null,
				LLUUID::null,
				perm,
				LLUUID::null,
				LLAssetType::AT_LSL_TEXT,
				LLInventoryType::IT_LSL,
				std::string("New Script"),
				desc,
				LLSaleInfo::DEFAULT,
				LLViewerInventoryItem::II_FLAGS_NONE,
				time_corrected());
		object->saveScript(new_item, TRUE, true);

		// *NOTE: In order to resolve SL-22177, we needed to create
		// the script first, and then you have to click it in
		// inventory to edit it.
		// *TODO: The script creation should round-trip back to the
		// viewer so the viewer can auto-open the script and start
		// editing ASAP.
#if 0
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);
		LLRect rect = gSavedSettings.getRect("PreviewScriptRect");
		rect.translate( left - rect.mLeft, top - rect.mTop );

		LLLiveLSLEditor* editor;
		editor = new LLLiveLSLEditor("script ed",
									   rect,
									   "Script: New Script",
									   object->mID,
									   LLUUID::null);
		editor->open();	/*Flawfinder: ignore*/

		// keep onscreen
		gFloaterView->adjustToFitScreen(editor, FALSE);
#endif
	}
}
Example #19
0
// 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

	// 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());

	// 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());

	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())
	{
		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
	}

	LLViewerRegion *region = gAgent.getRegion();
	LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

	LLRect buttonRect;

	if (LLHUDIcon::iconsNearby())
	{
		childGetRect( "scriptout", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect("scriptout",r);
		childSetVisible("scriptout", true);
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("scriptout", false);
	}

	if ((region && region->getAllowDamage()) ||
		(parcel && parcel->getAllowDamage()) )
	{
		// set visibility based on flashing
		if( mHealthTimer->hasExpired() )
		{
			childSetVisible("health", true);
		}
		else
		{
			BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
			childSetVisible("health", flash);
		}
		mTextHealth->setVisible(TRUE);

		// Health
		childGetRect( "health", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect("health", r);
		x += buttonRect.getWidth();

		const S32 health_width = S32( LLFontGL::getFontSansSerifSmall()->getWidth(std::string("100%")) );
		r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
		mTextHealth->setRect(r);
		x += health_width;
	}
	else
	{
		// invisible if region doesn't allow damage
		childSetVisible("health", false);
		mTextHealth->setVisible(FALSE);
	}

	if ((region && region->getBlockFly()) ||
		(parcel && !parcel->getAllowFly()) )
	{
		// No Fly Zone
		childGetRect( "no_fly", buttonRect );
		childSetVisible( "no_fly", true );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_fly", r );
		x += buttonRect.getWidth();
	}
	else
	{
		// Fly Zone
		childSetVisible("no_fly", false);
	}

	BOOL no_build = parcel && !parcel->getAllowModify();
	if (no_build)
	{
		childSetVisible("no_build", TRUE);
		childGetRect( "no_build", buttonRect );
		// No Build Zone
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_build", r );
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("no_build", FALSE);
	}

	BOOL no_scripts = FALSE;
	if((region
		&& ((region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
		|| (region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)))
		|| (parcel && !parcel->getAllowOtherScripts()))
	{
		no_scripts = TRUE;
	}
	if (no_scripts)
	{
		// No scripts
		childSetVisible("no_scripts", TRUE);
		childGetRect( "no_scripts", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_scripts", r );
		x += buttonRect.getWidth();
	}
	else
	{
		// Yes scripts
		childSetVisible("no_scripts", FALSE);
	}

	BOOL no_region_push = (region && region->getRestrictPushObject());
	BOOL no_push = no_region_push || (parcel && parcel->getRestrictPushObject());
	if (no_push)
	{
		childSetVisible("restrictpush", TRUE);
		childGetRect( "restrictpush", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "restrictpush", r );
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("restrictpush", FALSE);
	}

	BOOL have_voice = parcel && parcel->getParcelFlagAllowVoice(); 
	if (have_voice)
	{
		childSetVisible("status_no_voice", FALSE);
	}
	else
	{
		childSetVisible("status_no_voice", TRUE);
		childGetRect( "status_no_voice", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "status_no_voice", r );
		x += buttonRect.getWidth();
	}

	BOOL canBuyLand = parcel
		&& !parcel->isPublic()
		&& LLViewerParcelMgr::getInstance()->canAgentBuyParcel(parcel, false);
	childSetVisible("buyland", canBuyLand);
	if (canBuyLand)
	{
		//HACK: layout tweak until this is all xml
		x += 9;
		childGetRect( "buyland", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "buyland", r );
		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;
	}

// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a
	if ( (region) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )	// region == NULL if we loose our connection to the grid
	{
		// TODO-RLVa: find out whether the LCD code is still used because if so then we need to filter that as well
		location_name = llformat("%s (%s) - %s", 
			rlv_handler_t::cstrHiddenRegion.c_str(), region->getSimAccessString().c_str(), rlv_handler_t::cstrHidden.c_str());
	}
// [/RLVa:KB]

	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);

	// Set search bar visibility
	childSetVisible("search_editor", search_visible);
	childSetVisible("search_btn", search_visible);
	childSetVisible("menubar_search_bevel_bg", search_visible);
	mSGBandwidth->setVisible(! search_visible);
	mSGPacketLoss->setVisible(! search_visible);
	childSetEnabled("stat_btn", ! search_visible);
}
Example #20
0
// static
void LLPanelContents::onClickNewScript(void *userdata)
{
	const BOOL children_ok = TRUE;
	LLViewerObject* object = gSelectMgr->getSelection()->getFirstRootObject(children_ok);
	if(object)
	{
//MK
		if (RRenabled)
		{
			// can't edit objects that someone is sitting on,
			// when prevented from sit-tping
			if (gAgent.mRRInterface.contains ("sittp") || gAgent.mRRInterface.mContainsUnsit)
			{
				if (object->isSeat())
				{
					return;
				}
			}

			if (!gAgent.mRRInterface.isAllowed (object->getRootEdit()->getID(), "detach"))
			{
				return;
			}

			LLVOAvatar *avatarp = gAgent.getAvatarObject();
			LLUUID inv_item_id = LLUUID::null;
			LLInventoryItem* inv_item = gAgent.mRRInterface.getItem(object->getRootEdit()->getID());
			if (inv_item) inv_item_id = inv_item->getUUID();
			if (avatarp && gAgent.mRRInterface.contains("detach:"+avatarp->getAttachedPointName(inv_item_id)))
			{
				return;
			}
		}
//mk
		LLPermissions perm;
		perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
		perm.initMasks(
			PERM_ALL,
			PERM_ALL,
			PERM_NONE,
			PERM_NONE,
			PERM_MOVE | PERM_TRANSFER);
		LLString desc;
		LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc);
		LLPointer<LLViewerInventoryItem> new_item =
			new LLViewerInventoryItem(
				LLUUID::null,
				LLUUID::null,
				perm,
				LLUUID::null,
				LLAssetType::AT_LSL_TEXT,
				LLInventoryType::IT_LSL,
				LLString("New Script"),
				desc,
				LLSaleInfo::DEFAULT,
				LLViewerInventoryItem::II_FLAGS_NONE,
				time_corrected());
		object->saveScript(new_item, TRUE, true);

		// *NOTE: In order to resolve SL-22177, we needed to create
		// the script first, and then you have to click it in
		// inventory to edit it.
		// *TODO: The script creation should round-trip back to the
		// viewer so the viewer can auto-open the script and start
		// editing ASAP.
#if 0
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);
		LLRect rect = gSavedSettings.getRect("PreviewScriptRect");
		rect.translate( left - rect.mLeft, top - rect.mTop );

		LLLiveLSLEditor* editor;
		editor = new LLLiveLSLEditor("script ed",
									   rect,
									   "Script: New Script",
									   object->mID,
									   LLUUID::null);
		editor->open();	/*Flawfinder: ignore*/

		// keep onscreen
		gFloaterView->adjustToFitScreen(editor, FALSE);
#endif
	}
}
Example #21
0
// static
BOOL LLFloaterEditUI::processKeystroke(KEY key, MASK mask)
{
	if (!LLView::sEditingUIView) return FALSE;

	S32 step = 2;
	BOOL handled = FALSE;
	LLRect r = LLView::sEditingUIView->getRect();

	if (mask == MASK_NONE)
	{
		if (key == KEY_RIGHT)
		{
			r.translate(step,0);
			handled = TRUE;
		}
		else if (key == KEY_LEFT)
		{
			r.translate(-step,0);
			handled = TRUE;
		}
		else if (key == KEY_UP)
		{
			r.translate(0,step);
			handled = TRUE;
		}
		else if (key == KEY_DOWN)
		{
			r.translate(0,-step);
			handled = TRUE;
		}
	}
	else if (mask == MASK_SHIFT)
	{
		if (key == KEY_RIGHT)
		{
			r.mRight += step;
			handled = TRUE;
		}
		else if (key == KEY_LEFT)
		{
			r.mRight -= step;
			handled = TRUE;
		}
		else if (key == KEY_UP)
		{
			r.mTop += step;
			handled = TRUE;
		}
		else if (key == KEY_DOWN)
		{
			r.mTop -= step;
			handled = TRUE;
		}
	}

	if (handled)
	{
		LLView::sEditingUIView->reshape(r.getWidth(), r.getHeight());
		LLView::sEditingUIView->setRect(r);
		if (sInstance) sInstance->refreshCore();
	}

	return handled;
}
void LLLocalInventory::open(LLUUID item_id)
{
    LLViewerInventoryItem* item = gInventory.getItem(item_id);
    if(!item)
    {
        llwarns << "Trying to open non-existent item" << llendl;
        return;
    }

    LLAssetType::EType type = item->getType();

    if(type == LLAssetType::AT_SOUND)
    {
        S32 left, top;
        gFloaterView->getNewFloaterPosition(&left, &top);
        LLRect rect = gSavedSettings.getRect("PreviewSoundRect");
        rect.translate(left - rect.mLeft, top - rect.mTop);
        LLPreviewSound* floaterp;
        floaterp = 	new LLPreviewSound("Preview sound",
                                       rect,
                                       "",
                                       item_id);
        floaterp->setFocus(TRUE);
        gFloaterView->adjustToFitScreen(floaterp, FALSE);
    }
    else if(type == LLAssetType::AT_ANIMATION)
    {
        S32 left, top;
        gFloaterView->getNewFloaterPosition(&left, &top);
        LLRect rect = gSavedSettings.getRect("PreviewAnimRect");
        rect.translate(left - rect.mLeft, top - rect.mTop);
        LLPreviewAnim* floaterp;
        floaterp = 	new LLPreviewAnim("Preview anim",
                                      rect,
                                      "",
                                      item_id,
                                      LLPreviewAnim::NONE);
        floaterp->setFocus(TRUE);
        gFloaterView->adjustToFitScreen(floaterp, FALSE);
    }
    else if(type == LLAssetType::AT_TEXTURE)
    {
        S32 left, top;
        gFloaterView->getNewFloaterPosition(&left, &top);
        LLRect rect = gSavedSettings.getRect("PreviewTextureRect");
        rect.translate( left - rect.mLeft, top - rect.mTop );

        LLPreviewTexture* preview;
        preview = new LLPreviewTexture("preview texture",
                                       rect,
                                       "Preview texture",
                                       item_id,
                                       LLUUID::null,
                                       FALSE);
        //preview->setSourceID(source_id);
        preview->setFocus(TRUE);

        gFloaterView->adjustToFitScreen(preview, FALSE);
    }
    else if(type == LLAssetType::AT_GESTURE)
    {
        // If only the others were like this
        LLPreviewGesture::show("preview gesture", item_id, LLUUID::null, TRUE);
    }
    else if(type == LLAssetType::AT_LANDMARK)
    {
        S32 left, top;
        gFloaterView->getNewFloaterPosition(&left, &top);
        LLRect rect = gSavedSettings.getRect("PreviewLandmarkRect");
        rect.translate( left - rect.mLeft, top - rect.mTop );

        LLPreviewLandmark* preview;
        preview = new LLPreviewLandmark("preview landmark",
                                        rect,
                                        "Preview landmark",
                                        item_id);
        preview->setFocus(TRUE);

        gFloaterView->adjustToFitScreen(preview, FALSE);
    }
    else
    {
        llwarns << "Dunno how to open type " << type << llendl;
    }
}
Example #23
0
// Per-frame updates of visibility
void LLStatusBar::refresh()
{
 	if(gDisconnected)
 		return; //or crash if the sim crashes; because: already ~LLMenuBarGL()

	// 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);

	// Let's not have to reformat time everywhere, shall we? -- MC
	gViewerTime->refresh();
	mTextTime->setText(gViewerTime->getCurTimeStr());
	mTextTime->setToolTip(gViewerTime->getCurDateStr());

	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())
	{
		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
	}

	LLViewerRegion *region = gAgent.getRegion();
	LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

	LLRect buttonRect;

	if (LLHUDIcon::iconsNearby())
	{
		childGetRect( "scriptout", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect("scriptout",r);
		childSetVisible("scriptout", true);
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("scriptout", false);
	}

	if ((region && region->getAllowDamage()) ||
		(parcel && parcel->getAllowDamage()) )
	{
		// set visibility based on flashing
		if( mHealthTimer->hasExpired() )
		{
			childSetVisible("health", true);
		}
		else
		{
			BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
			childSetVisible("health", flash);
		}
		mTextHealth->setVisible(TRUE);

		// Health
		childGetRect( "health", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect("health", r);
		x += buttonRect.getWidth();

		const S32 health_width = S32( LLFontGL::getFontSansSerifSmall()->getWidth(std::string("100%")) );
		r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
		mTextHealth->setRect(r);
		x += health_width;
	}
	else
	{
		// invisible if region doesn't allow damage
		childSetVisible("health", false);
		mTextHealth->setVisible(FALSE);
	}

	if ((region && region->getBlockFly()) ||
		(parcel && !parcel->getAllowFly()) )
	{
		// No Fly Zone
		childGetRect( "no_fly", buttonRect );
		childSetVisible( "no_fly", true );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_fly", r );
		x += buttonRect.getWidth();
	}
	else
	{
		// Fly Zone
		childSetVisible("no_fly", false);
	}

	BOOL no_build = parcel && !parcel->getAllowModify();
	if (no_build)
	{
		childSetVisible("no_build", TRUE);
		childGetRect( "no_build", buttonRect );
		// No Build Zone
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_build", r );
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("no_build", FALSE);
	}

	BOOL no_scripts = FALSE;
	if((region
		&& ((region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
		|| (region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)))
		|| (parcel && !parcel->getAllowOtherScripts()))
	{
		no_scripts = TRUE;
	}
	if (no_scripts)
	{
		// No scripts
		childSetVisible("no_scripts", TRUE);
		childGetRect( "no_scripts", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_scripts", r );
		x += buttonRect.getWidth();
	}
	else
	{
		// Yes scripts
		childSetVisible("no_scripts", FALSE);
	}

	BOOL no_region_push = (region && region->getRestrictPushObject());
	BOOL no_push = no_region_push || (parcel && parcel->getRestrictPushObject());
	if (no_push)
	{
		childSetVisible("restrictpush", TRUE);
		childGetRect( "restrictpush", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "restrictpush", r );
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("restrictpush", FALSE);
	}

	BOOL have_voice = parcel && parcel->getParcelFlagAllowVoice(); 
	if (have_voice)
	{
		childSetVisible("status_no_voice", FALSE);
	}
	else
	{
		childSetVisible("status_no_voice", TRUE);
		childGetRect( "status_no_voice", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "status_no_voice", r );
		x += buttonRect.getWidth();
	}

	// TODO: disable buy land button when connected to non-SL grids
	// that don't support currency.
	// TODO: make this brandable -- MC
	BOOL canBuyLand = parcel
		&& !parcel->isPublic()
		&& LLViewerParcelMgr::getInstance()->canAgentBuyParcel(parcel, false);
	childSetVisible("buyland", canBuyLand);
	if (canBuyLand)
	{
		//HACK: layout tweak until this is all xml
		x += 9;
		childGetRect( "buyland", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "buyland", r );
		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;
	}

// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a
	if ( (region) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )	// region == NULL if we loose our connection to the grid
	{
		// TODO-RLVa: find out whether the LCD code is still used because if so then we need to filter that as well
		location_name = llformat("%s (%s) - %s", 
			rlv_handler_t::cstrHiddenRegion.c_str(), region->getSimAccessString().c_str(), rlv_handler_t::cstrHidden.c_str());
	}
// [/RLVa:KB]

	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;

	// Don't toggle this visibility while in mouselook -- MC
	if (!gAgent.cameraMouselook())
	{
		// Set search bar visibility
		childSetVisible("search_editor", search_visible);
		childSetVisible("search_btn", search_visible);
		childSetVisible("menubar_search_bevel_bg", search_visible);
		mSGBandwidth->setVisible(! search_visible);
		mSGPacketLoss->setVisible(! search_visible);
		childSetEnabled("stat_btn", ! search_visible);
	}

	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);
}
// Per-frame updates of visibility
void LLStatusBar::refresh()
{
	if(gDisconnected)
	return; //or crash if the sim crashes; because: already ~LLMenuBarGL()

	// 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

	// 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);

	std::string t;
	timeStructToFormattedString(internal_time, gSavedSettings.getString("ShortTimeFormat"), t);
	if (gPacificDaylightTime)
	{
		t += " PDT";
	}
	else
	{
		t += " PST";
	}
	mTextTime->setText(t);

	std::string date;
	timeStructToFormattedString(internal_time, gSavedSettings.getString("LongDateFormat"), date);
	mTextTime->setToolTip(date);

	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())
	{
		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
	}

	LLViewerRegion *region = gAgent.getRegion();
	LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

	LLRect buttonRect;

	if (LLHUDIcon::iconsNearby())
	{
		childGetRect( "scriptout", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect("scriptout",r);
		childSetVisible("scriptout", true);
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("scriptout", false);
	}

	if ((region && region->getAllowDamage()) ||
		(parcel && parcel->getAllowDamage()) )
	{
		// set visibility based on flashing
		if( mHealthTimer->hasExpired() )
		{
			childSetVisible("health", true);
		}
		else
		{
			BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
			childSetVisible("health", flash);
		}
		mTextHealth->setVisible(TRUE);

		// Health
		childGetRect( "health", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect("health", r);
		x += buttonRect.getWidth();

		const S32 health_width = S32( LLFontGL::getFontSansSerifSmall()->getWidth(std::string("100%")) );
		r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
		mTextHealth->setRect(r);
		x += health_width;
	}
	else
	{
		// invisible if region doesn't allow damage
		childSetVisible("health", false);
		mTextHealth->setVisible(FALSE);
	}

	if ((region && region->getBlockFly()) ||
		(parcel && !parcel->getAllowFly()) )
	{
		// No Fly Zone
		childGetRect( "no_fly", buttonRect );
		childSetVisible( "no_fly", true );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_fly", r );
		x += buttonRect.getWidth();
	}
	else
	{
		// Fly Zone
		childSetVisible("no_fly", false);
	}

	BOOL no_build = parcel && !parcel->getAllowModify();
	if (no_build)
	{
		childSetVisible("no_build", TRUE);
		childGetRect( "no_build", buttonRect );
		// No Build Zone
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_build", r );
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("no_build", FALSE);
	}

	BOOL no_scripts = FALSE;
	if((region
		&& (region->getRegionFlag(REGION_FLAGS_SKIP_SCRIPTS)
		|| region->getRegionFlag(REGION_FLAGS_ESTATE_SKIP_SCRIPTS)))
		|| (parcel && !parcel->getAllowOtherScripts()))
	{
		no_scripts = TRUE;
	}
	if (no_scripts)
	{
		// No scripts
		childSetVisible("no_scripts", TRUE);
		childGetRect( "no_scripts", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "no_scripts", r );
		x += buttonRect.getWidth();
	}
	else
	{
		// Yes scripts
		childSetVisible("no_scripts", FALSE);
	}

	BOOL no_region_push = (region && region->getRestrictPushObject());
	BOOL no_push = no_region_push || (parcel && parcel->getRestrictPushObject());
	if (no_push)
	{
		childSetVisible("restrictpush", TRUE);
		childGetRect( "restrictpush", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "restrictpush", r );
		x += buttonRect.getWidth();
	}
	else
	{
		childSetVisible("restrictpush", FALSE);
	}

	BOOL have_voice = parcel && parcel->getParcelFlagAllowVoice(); 
	if (have_voice)
	{
		childSetVisible("status_no_voice", FALSE);
	}
	else
	{
		childSetVisible("status_no_voice", TRUE);
		childGetRect( "status_no_voice", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "status_no_voice", r );
		x += buttonRect.getWidth();
	}

	bool no_see_avs = parcel && !parcel->getSeeAVs();
	childSetVisible("status_SeeAV", no_see_avs);
	if (no_see_avs)
	{
		childGetRect( "status_SeeAV", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "status_SeeAV", r );
		x += buttonRect.getWidth();
	}

	if (region)
	{
		bool pf_disabled = !region->dynamicPathfindingEnabled();
		getChild<LLUICtrl>("pf_dirty")->setVisible(!pf_disabled && mIsNavMeshDirty);
		getChild<LLUICtrl>("pf_disabled")->setVisible(pf_disabled);
		const std::string pf_icon = pf_disabled ? "pf_disabled" : mIsNavMeshDirty ? "pf_dirty" : "";
		if (!pf_icon.empty())
		{
			x += 6;
			childGetRect(pf_icon, buttonRect);
			r.setOriginAndSize(x, y, buttonRect.getWidth(), buttonRect.getHeight());
			childSetRect(pf_icon, r);
			x += buttonRect.getWidth();
		}
	}

	BOOL canBuyLand = parcel
		&& !parcel->isPublic()
		&& LLViewerParcelMgr::getInstance()->canAgentBuyParcel(parcel, false);
	childSetVisible("buyland", canBuyLand);
	if (canBuyLand)
	{
		//HACK: layout tweak until this is all xml
		x += 9;
		childGetRect( "buyland", buttonRect );
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		childSetRect( "buyland", r );
		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;
		}

		if (parcel)
		{
			if (!LLAgentUI::buildLocationString(location_name, LLAgentUI::LOCATION_FORMAT_FULL)) 
			{
				location_name = "???";
			}
		}
		else
		{
			location_name = region->getName()
				+ llformat(" %d, %d, %d (%s)", 
						   pos_x, pos_y, pos_z,
						   region->getSimAccessString().c_str());
		}
		static LLCachedControl<bool> show_channel("ShowSimChannel");
		if (show_channel && !gLastVersionChannel.empty()) location_name += " - " + gLastVersionChannel;
	}
	else
	{
		// no region
		location_name = "(Unknown)";
	}

// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a
	if ( (region) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )	// region == NULL if we lose our connection to the grid
	{
		location_name = llformat("%s (%s) - %s", 
			RlvStrings::getString(RLV_STRING_HIDDEN_REGION).c_str(), region->getSimAccessString().c_str(), 
			RlvStrings::getString(RLV_STRING_HIDDEN).c_str());
	}
// [/RLVa:KB]

	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
	if (mUPCSupported)
	{
		childGetRect("UPCText", r);
		r.translate( new_right - r.mRight, 0);
		childSetRect("UPCText", r);
		new_right -= r.getWidth() - 18;
	}

	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);

	// Set search bar visibility
	childSetVisible("search_editor", search_visible);
	childSetVisible("search_btn", search_visible);
	childSetVisible("menubar_search_bevel_bg", search_visible);
	mSGBandwidth->setVisible(! search_visible);
	mSGPacketLoss->setVisible(! search_visible);
	childSetEnabled("stat_btn", ! search_visible);
}
void LLScrollContainer::updateScroll()
{
	if (!mScrolledView)
	{
		return;
	}
	static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
	LLRect doc_rect = mScrolledView->getRect();
	S32 doc_width = doc_rect.getWidth();
	S32 doc_height = doc_rect.getHeight();
	S32 visible_width = 0;
	S32 visible_height = 0;
	BOOL show_v_scrollbar = FALSE;
	BOOL show_h_scrollbar = FALSE;
	calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );

	S32 border_width = getBorderWidth();
	if( show_v_scrollbar )
	{
		if( doc_rect.mTop < getRect().getHeight() - border_width )
		{
			mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop );
		}

		scrollVertical(	mScrollbar[VERTICAL]->getDocPos() );
		mScrollbar[VERTICAL]->setVisible( TRUE );

		S32 v_scrollbar_height = visible_height;
		if( !show_h_scrollbar && mReserveScrollCorner )
		{
			v_scrollbar_height -= scrollbar_size;
		}
		mScrollbar[VERTICAL]->reshape( scrollbar_size, v_scrollbar_height, TRUE );

		// Make room for the horizontal scrollbar (or not)
		S32 v_scrollbar_offset = 0;
		if( show_h_scrollbar || mReserveScrollCorner )
		{
			v_scrollbar_offset = scrollbar_size;
		}
		LLRect r = mScrollbar[VERTICAL]->getRect();
		r.translate( 0, mInnerRect.mBottom - r.mBottom + v_scrollbar_offset );
		mScrollbar[VERTICAL]->setRect( r );
	}
	else
	{
		mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop );

		mScrollbar[VERTICAL]->setVisible( FALSE );
		mScrollbar[VERTICAL]->setDocPos( 0 );
	}
		
	if( show_h_scrollbar )
	{
		if( doc_rect.mLeft > border_width )
		{
			mScrolledView->translate( border_width - doc_rect.mLeft, 0 );
			mScrollbar[HORIZONTAL]->setDocPos( 0 );
		}
		else
		{
			scrollHorizontal( mScrollbar[HORIZONTAL]->getDocPos() );
		}
	
		mScrollbar[HORIZONTAL]->setVisible( TRUE );
		S32 h_scrollbar_width = visible_width;
		if( !show_v_scrollbar && mReserveScrollCorner )
		{
			h_scrollbar_width -= scrollbar_size;
		}
		mScrollbar[HORIZONTAL]->reshape( h_scrollbar_width, scrollbar_size, TRUE );
	}
	else
	{
		mScrolledView->translate( border_width - doc_rect.mLeft, 0 );
		
		mScrollbar[HORIZONTAL]->setVisible( FALSE );
		mScrollbar[HORIZONTAL]->setDocPos( 0 );
	}

	mScrollbar[HORIZONTAL]->setDocSize( doc_width );
	mScrollbar[HORIZONTAL]->setPageSize( visible_width );

	mScrollbar[VERTICAL]->setDocSize( doc_height );
	mScrollbar[VERTICAL]->setPageSize( visible_height );
} // end updateScroll
// Per-frame updates of visibility
void LLStatusBar::refresh()
{
	if(gDisconnected)
	return; //or crash if the sim crashes; because: already ~LLMenuBarGL()

	// 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);

	// Singu Note: Use system's time if the user desires, otherwise use server time
	static const LLCachedControl<bool> show_local_time("LiruLocalTime");

	// Get current UTC time, adjusted for the user's clock
	// being off.
	time_t utc_time = show_local_time ? time(NULL) : 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 = show_local_time ? std::localtime(&utc_time) : utc_to_pacific_time(utc_time, gPacificDaylightTime);

	static const LLCachedControl<std::string> short_time_fmt(gSavedSettings, "ShortTimeFormat");
	std::string t;
	timeStructToFormattedString(internal_time, short_time_fmt, t);
	if (show_local_time)
	{
		static const std::string local(" " + getString("Local"));
		t += local;
	}
	else if (gPacificDaylightTime)
	{
		t += " PDT";
	}
	else
	{
		t += " PST";
	}
	mTextTime->setText(t);

	static const LLCachedControl<std::string> long_date_fmt(gSavedSettings, "LongDateFormat");
	std::string date;
	timeStructToFormattedString(internal_time, long_date_fmt, date);
	mTextTime->setToolTip(date);

	LLRect r;
	const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
	S32 x = MENU_RIGHT + MENU_PARCEL_SPACING;
	S32 y = 0;

	// reshape menu bar to its content's width
	if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
	{
		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
	}

	LLViewerRegion *region = gAgent.getRegion();
	LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

	if (LLHUDIcon::iconsNearby())
	{
		const LLRect& buttonRect = mScriptOut->getRect();
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mScriptOut->setRect(r);
		mScriptOut->setVisible(true);
		x += buttonRect.getWidth();
	}
	else
	{
		mScriptOut->setVisible(false);
	}

	if ((region && region->getAllowDamage()) ||
		(parcel && parcel->getAllowDamage()) )
	{
		// set visibility based on flashing
		mHealthV->setVisible(mHealthTimer->hasExpired() || S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1);
		mTextHealth->setVisible(TRUE);

		// Health
		const LLRect& buttonRect = mHealthV->getRect();
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mHealthV->setRect(r);
		x += buttonRect.getWidth();

		const S32 health_width = S32( LLFontGL::getFontSansSerifSmall()->getWidth(std::string("100%")) );
		r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
		mTextHealth->setRect(r);
		x += health_width;
	}
	else
	{
		// invisible if region doesn't allow damage
		mHealthV->setVisible(false);
		mTextHealth->setVisible(FALSE);
	}

	if ((region && region->getBlockFly()) ||
		(parcel && !parcel->getAllowFly()) )
	{
		// No Fly Zone
		mNoFly->setVisible(true);
		const LLRect& buttonRect(mNoFly->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mNoFly->setRect(r);
		x += buttonRect.getWidth();
	}
	else
	{
		// Fly Zone
		mNoFly->setVisible(false);
	}

	if (parcel && !parcel->getAllowModify())
	{
		// No Build Zone
		mNoBuild->setVisible(true);
		const LLRect& buttonRect(mNoBuild->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mNoBuild->setRect(r);
		x += buttonRect.getWidth();
	}
	else
	{
		mNoBuild->setVisible(false);
	}

	if ((region
		&& (region->getRegionFlag(REGION_FLAGS_SKIP_SCRIPTS)
		|| region->getRegionFlag(REGION_FLAGS_ESTATE_SKIP_SCRIPTS)))
		|| (parcel && !parcel->getAllowOtherScripts()))
	{
		// No scripts
		mNoScripts->setVisible(true);
		const LLRect& buttonRect(mNoScripts->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mNoScripts->setRect(r);
		x += buttonRect.getWidth();
	}
	else
	{
		// Yes scripts
		mNoScripts->setVisible(false);
	}

	if ((region && region->getRestrictPushObject()) || (parcel && parcel->getRestrictPushObject()))
	{
		mRestrictPush->setVisible(true);
		const LLRect& buttonRect(mRestrictPush->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mRestrictPush->setRect(r);
		x += buttonRect.getWidth();
	}
	else
	{
		mRestrictPush->setVisible(false);
	}

	if (parcel && parcel->getParcelFlagAllowVoice())
	{
		mStatusNoVoice->setVisible(false);
	}
	else
	{
		mStatusNoVoice->setVisible(true);
		const LLRect& buttonRect(mStatusNoVoice->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mStatusNoVoice->setRect(r);
		x += buttonRect.getWidth();
	}

	if (parcel && !parcel->getSeeAVs())
	{
		mStatusSeeAV->setVisible(true);
		const LLRect& buttonRect(mStatusSeeAV->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mStatusSeeAV->setRect(r);
		x += buttonRect.getWidth();
	}
	else mStatusSeeAV->setVisible(false);

	if (region)
	{
		bool pf_disabled = !region->dynamicPathfindingEnabled();
		mPFDirty->setVisible(!pf_disabled && mIsNavMeshDirty);
		mPFDisabled->setVisible(pf_disabled);
		if (LLView* pf_icon = pf_disabled ? mPFDisabled : mIsNavMeshDirty ? mPFDirty : NULL)
		{
			x += 6;
			const LLRect& buttonRect(pf_icon->getRect());
			r.setOriginAndSize(x, y, buttonRect.getWidth(), buttonRect.getHeight());
			pf_icon->setRect(r);
			x += buttonRect.getWidth();
		}
	}

	if (parcel && !parcel->isPublic() && LLViewerParcelMgr::getInstance()->canAgentBuyParcel(parcel, false))
	{
		mBuyLand->setVisible(true);
		//HACK: layout tweak until this is all xml
		x += 9;
		const LLRect& buttonRect(mBuyLand->getRect());
		r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
		mBuyLand->setRect(r);
		x += buttonRect.getWidth();
	}
	else mBuyLand->setVisible(false);

	std::string location_name;
	if (region && parcel)
	{
// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a
		if (RlvActions::hasBehaviour(RLV_BHVR_SHOWLOC))
		{
			location_name = llformat("%s (%s) - %s",
					RlvStrings::getString(RLV_STRING_HIDDEN_REGION).c_str(), region->getSimAccessString().c_str(), 
					RlvStrings::getString(RLV_STRING_HIDDEN).c_str());
		}
		else
// [/RLVa:KB]
		if (!LLAgentUI::buildLocationString(location_name, LLAgentUI::LOCATION_FORMAT_FULL)) 
			location_name = "???";
		else
		{
			const std::string& grid(LFSimFeatureHandler::instance().gridName());
			if (!grid.empty()) location_name += ", " + grid;
		}

		static const LLCachedControl<bool> show_channel("ShowSimChannel");
		if (show_channel && !gLastVersionChannel.empty()) location_name += " - " + gLastVersionChannel;
	}
	else
	{
		// no region
		location_name = "(Unknown)";
	}

	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();
	static const LLCachedControl<bool> search_visible(gSavedSettings, "ShowSearchBar");
	if (search_visible)
	{
		new_right -= mSearchBtn->getRect().getWidth();
		new_right -= mSearchEditor->getRect().getWidth() + 6;
	}
	else
	{
		r = mStatBtn->getRect();
		r.translate( new_right - r.mRight, 0);
		mStatBtn->setRect(r);
		new_right -= r.getWidth() + 6;
	}

	// Set search bar visibility
	mSearchEditor->setVisible(search_visible);
	mSearchBtn->setVisible(search_visible);
	mSearchBevel->setVisible(search_visible);
	mSGBandwidth->setVisible(! search_visible);
	mSGPacketLoss->setVisible(! search_visible);
	mStatBtn->setEnabled(!search_visible);

	// Set rects of money, buy money, time
	if (mUPCSupported)
	{
		r = mTextUPC->getRect();
		r.translate( new_right - r.mRight, 0);
		mTextUPC->setRect(r);
		new_right -= r.getWidth() - 18;
	}

	r = mTextBalance->getRect();
	r.translate( new_right - r.mRight, 0);
	mTextBalance->setRect(r);
	new_right -= r.getWidth() - 18;

	r = mBuyCurrency->getRect();
	r.translate( new_right - r.mRight, 0);
	mBuyCurrency->setRect(r);
	new_right -= r.getWidth() + 6;

	r = mTextTime->getRect();
	r.translate( new_right - r.mRight, 0);
	mTextTime->setRect(r);

	// 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);
}