コード例 #1
0
void LLFloaterBuyLandUI::refreshUI()
{
	// section zero: title area
	{
		LLTextureCtrl* snapshot = getChild<LLTextureCtrl>("info_image");
		if (snapshot)
		{
			snapshot->setImageAssetID(
				mParcelValid ? mParcelSnapshot : LLUUID::null);
		}
		
		if (mParcelValid)
		{
			getChild<LLUICtrl>("info_parcel")->setValue(mParcelLocation);

			LLStringUtil::format_map_t string_args;
			string_args["[AMOUNT]"] = llformat("%d", mParcelActualArea);
			string_args["[AMOUNT2]"] = llformat("%d", mParcelSupportedObjects);
		
			getChild<LLUICtrl>("info_size")->setValue(getString("meters_supports_object", string_args));

			F32 cost_per_sqm = 0.0f;
			if (mParcelActualArea > 0)
			{
				cost_per_sqm = (F32)mParcelPrice / (F32)mParcelActualArea;
			}

			LLStringUtil::format_map_t info_price_args;
			info_price_args["[PRICE]"] = llformat("%d", mParcelPrice);
			info_price_args["[PRICE_PER_SQM]"] = llformat("%.1f", cost_per_sqm);
			if (mParcelSoldWithObjects)
			{
				info_price_args["[SOLD_WITH_OBJECTS]"] = getString("sold_with_objects");
			}
			else
			{
				info_price_args["[SOLD_WITH_OBJECTS]"] = getString("sold_without_objects");
			}
			getChild<LLUICtrl>("info_price")->setValue(getString("info_price_string", info_price_args));
			getChildView("info_price")->setVisible( mParcelIsForSale);
		}
		else
		{
			getChild<LLUICtrl>("info_parcel")->setValue(getString("no_parcel_selected"));
			getChild<LLUICtrl>("info_size")->setValue(LLStringUtil::null);
			getChild<LLUICtrl>("info_price")->setValue(LLStringUtil::null);
		}
		
		getChild<LLUICtrl>("info_action")->setValue(
			mCanBuy
				?
					mIsForGroup
						? getString("buying_for_group")//"Buying land for group:"
						: getString("buying_will")//"Buying this land will:"
				: 
					mCannotBuyIsError
						? getString("cannot_buy_now")//"Cannot buy now:"
						: getString("not_for_sale")//"Not for sale:"

			);
	}
	
	bool showingError = !mCanBuy || !mSiteValid;
	
	// error section
	if (showingError)
	{
		mChildren.setBadge(std::string("step_error"),
			mCannotBuyIsError
				? LLViewChildren::BADGE_ERROR
				: LLViewChildren::BADGE_WARN);
		
		LLTextBox* message = getChild<LLTextBox>("error_message");
		if (message)
		{
			message->setVisible(true);
			message->setValue(LLSD(!mCanBuy ? mCannotBuyReason : "(waiting for data)"));
		}

		getChildView("error_web")->setVisible(mCannotBuyIsError && !mCannotBuyURI.empty());
	}
	else
	{
		getChildView("step_error")->setVisible(FALSE);
		getChildView("error_message")->setVisible(FALSE);
		getChildView("error_web")->setVisible(FALSE);
	}
	
	
	// section one: account
	if (!showingError)
	{
		mChildren.setBadge(std::string("step_1"),
			mSiteMembershipUpgrade
				? LLViewChildren::BADGE_NOTE
				: LLViewChildren::BADGE_OK);
		getChild<LLUICtrl>("account_action")->setValue(mSiteMembershipAction);
		getChild<LLUICtrl>("account_reason")->setValue( 
			mSiteMembershipUpgrade
				?	getString("must_upgrade")
				:	getString("cant_own_land")
			);
		
		LLComboBox* levels = getChild<LLComboBox>( "account_level");
		if (levels)
		{
			levels->setVisible(mSiteMembershipUpgrade);
			
			levels->removeall();
			for(std::vector<std::string>::const_iterator i
					= mSiteMembershipPlanNames.begin();
				i != mSiteMembershipPlanNames.end();
				++i)
			{
				levels->add(*i);
			}
			
			levels->setCurrentByIndex(mUserPlanChoice);
		}

		getChildView("step_1")->setVisible(TRUE);
		getChildView("account_action")->setVisible(TRUE);
		getChildView("account_reason")->setVisible(TRUE);
	}
	else
	{
		getChildView("step_1")->setVisible(FALSE);
		getChildView("account_action")->setVisible(FALSE);
		getChildView("account_reason")->setVisible(FALSE);
		getChildView("account_level")->setVisible(FALSE);
	}
	
	// section two: land use fees
	if (!showingError)
	{
		mChildren.setBadge(std::string("step_2"),
			mSiteLandUseUpgrade
				? LLViewChildren::BADGE_NOTE
				: LLViewChildren::BADGE_OK);
		getChild<LLUICtrl>("land_use_action")->setValue(mSiteLandUseAction);
		
		std::string message;
		
		if (mIsForGroup)
		{
			LLStringUtil::format_map_t string_args;
			string_args["[GROUP]"] = std::string(gAgent.getGroupName());

			message += getString("insufficient_land_credits", string_args);
				
		}
		else
		{
			LLStringUtil::format_map_t string_args;
			string_args["[BUYER]"] = llformat("%d", mAgentCommittedTier);
			message += getString("land_holdings", string_args);
		}
		
		if (!mParcelValid)
		{
			message += LLTrans::getString("sentences_separator") + getString("no_parcel_selected");
		}
		else if (mParcelBillableArea == mParcelActualArea)
		{
			LLStringUtil::format_map_t string_args;
			string_args["[AMOUNT]"] = llformat("%d ", mParcelActualArea);
			message += LLTrans::getString("sentences_separator") + getString("parcel_meters", string_args);
		}
		else
		{

			if (mParcelBillableArea > mParcelActualArea)
			{	
				LLStringUtil::format_map_t string_args;
				string_args["[AMOUNT]"] = llformat("%d ", mParcelBillableArea);
				message += LLTrans::getString("sentences_separator") + getString("premium_land", string_args);
			}
			else
			{
				LLStringUtil::format_map_t string_args;
				string_args["[AMOUNT]"] = llformat("%d ", mParcelBillableArea);
				message += LLTrans::getString("sentences_separator") + getString("discounted_land", string_args);
			}
		}

		getChild<LLUICtrl>("land_use_reason")->setValue(message);

		getChildView("step_2")->setVisible(TRUE);
		getChildView("land_use_action")->setVisible(TRUE);
		getChildView("land_use_reason")->setVisible(TRUE);
	}
	else
	{
		getChildView("step_2")->setVisible(FALSE);
		getChildView("land_use_action")->setVisible(FALSE);
		getChildView("land_use_reason")->setVisible(FALSE);
	}
	
	// section three: purchase & currency
	S32 finalBalance = mAgentCashBalance + mCurrency.getAmount() - mParcelPrice;
	bool willHaveEnough = finalBalance >= 0;
	bool haveEnough = mAgentCashBalance >= mParcelPrice;
	S32 minContribution = llceil((F32)mParcelBillableArea / GROUP_LAND_BONUS_FACTOR);
	bool groupContributionEnough = mParcelGroupContribution >= minContribution;
	
	mCurrency.updateUI(!showingError  &&  !haveEnough);

	if (!showingError)
	{
		mChildren.setBadge(std::string("step_3"),
			!willHaveEnough
				? LLViewChildren::BADGE_WARN
				: mCurrency.getAmount() > 0
					? LLViewChildren::BADGE_NOTE
					: LLViewChildren::BADGE_OK);
			
		LLStringUtil::format_map_t string_args;
		string_args["[AMOUNT]"] = llformat("%d", mParcelPrice);
		string_args["[SELLER]"] = mParcelSellerName;
		getChild<LLUICtrl>("purchase_action")->setValue(getString("pay_to_for_land", string_args));
		getChildView("purchase_action")->setVisible( mParcelValid);
		
		std::string reasonString;

		if (haveEnough)
		{
			LLStringUtil::format_map_t string_args;
			string_args["[AMOUNT]"] = llformat("%d", mAgentCashBalance);

			getChild<LLUICtrl>("currency_reason")->setValue(getString("have_enough_lindens", string_args));
		}
		else
		{
			LLStringUtil::format_map_t string_args;
			string_args["[AMOUNT]"] = llformat("%d", mAgentCashBalance);
			string_args["[AMOUNT2]"] = llformat("%d", mParcelPrice - mAgentCashBalance);
			
			getChild<LLUICtrl>("currency_reason")->setValue(getString("not_enough_lindens", string_args));

			getChild<LLUICtrl>("currency_est")->setTextArg("[LOCAL_AMOUNT]", mCurrency.getLocalEstimate());
		}
		
		if (willHaveEnough)
		{
			LLStringUtil::format_map_t string_args;
			string_args["[AMOUNT]"] = llformat("%d", finalBalance);

			getChild<LLUICtrl>("currency_balance")->setValue(getString("balance_left", string_args));

		}
		else
		{
			LLStringUtil::format_map_t string_args;
			string_args["[AMOUNT]"] = llformat("%d", mParcelPrice - mAgentCashBalance);
	
			getChild<LLUICtrl>("currency_balance")->setValue(getString("balance_needed", string_args));
			
		}

		getChild<LLUICtrl>("remove_contribution")->setValue(LLSD(groupContributionEnough));
		getChildView("remove_contribution")->setEnabled(groupContributionEnough);
		bool showRemoveContribution = mParcelIsGroupLand
							&& (mParcelGroupContribution > 0);
		getChildView("remove_contribution")->setLabelArg("[AMOUNT]",
							llformat("%d", minContribution));
		getChildView("remove_contribution")->setVisible( showRemoveContribution);

		getChildView("step_3")->setVisible(TRUE);
		getChildView("purchase_action")->setVisible(TRUE);
		getChildView("currency_reason")->setVisible(TRUE);
		getChildView("currency_balance")->setVisible(TRUE);
	}
	else
	{
		getChildView("step_3")->setVisible(FALSE);
		getChildView("purchase_action")->setVisible(FALSE);
		getChildView("currency_reason")->setVisible(FALSE);
		getChildView("currency_balance")->setVisible(FALSE);
		getChildView("remove_group_donation")->setVisible(FALSE);
	}


	bool agrees_to_covenant = false;
	LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant");
	if (check)
	{
	    agrees_to_covenant = check->get();
	}

	getChildView("buy_btn")->setEnabled(mCanBuy  &&  mSiteValid  &&  willHaveEnough  &&  !mTransaction && agrees_to_covenant);
}
コード例 #2
0
BOOL LLPreviewGesture::postBuild()
{
	LLLineEditor* edit;
	LLComboBox* combo;
	LLButton* btn;
	LLScrollListCtrl* list;
	LLTextBox* text;
	LLCheckBoxCtrl* check;

	edit = LLViewerUICtrlFactory::getLineEditorByName(this, "trigger_editor");
	edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitCallback(onCommitSetDirty);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mTriggerEditor = edit;

	text = LLViewerUICtrlFactory::getTextBoxByName(this, "replace_text");
	text->setEnabled(FALSE);
	mReplaceText = text;

	edit = LLViewerUICtrlFactory::getLineEditorByName(this, "replace_editor");
	edit->setEnabled(FALSE);
	edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitCallback(onCommitSetDirty);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mReplaceEditor = edit;

	combo = LLViewerUICtrlFactory::getComboBoxByName(this, "modifier_combo");
	combo->setCommitCallback(onCommitSetDirty);
	combo->setCallbackUserData(this);
	mModifierCombo = combo;

	combo = LLViewerUICtrlFactory::getComboBoxByName(this, "key_combo");
	combo->setCommitCallback(onCommitSetDirty);
	combo->setCallbackUserData(this);
	mKeyCombo = combo;

	list = LLViewerUICtrlFactory::getScrollListByName(this, "library_list");
	list->setCommitCallback(onCommitLibrary);
	list->setDoubleClickCallback(onClickAdd);
	list->setCallbackUserData(this);
	mLibraryList = list;

	btn = LLViewerUICtrlFactory::getButtonByName(this, "add_btn");
	btn->setClickedCallback(onClickAdd);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mAddBtn = btn;

	btn = LLViewerUICtrlFactory::getButtonByName(this, "up_btn");
	btn->setClickedCallback(onClickUp);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mUpBtn = btn;

	btn = LLViewerUICtrlFactory::getButtonByName(this, "down_btn");
	btn->setClickedCallback(onClickDown);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mDownBtn = btn;

	btn = LLViewerUICtrlFactory::getButtonByName(this, "delete_btn");
	btn->setClickedCallback(onClickDelete);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mDeleteBtn = btn;

	list = LLViewerUICtrlFactory::getScrollListByName(this, "step_list");
	list->setCommitCallback(onCommitStep);
	list->setCallbackUserData(this);
	mStepList = list;

	// Options
	text = LLViewerUICtrlFactory::getTextBoxByName(this, "options_text");
	text->setBorderVisible(TRUE);
	mOptionsText = text;

	combo = LLViewerUICtrlFactory::getComboBoxByName(this, "animation_list");
	combo->setVisible(FALSE);
	combo->setCommitCallback(onCommitAnimation);
	combo->setCallbackUserData(this);
	mAnimationCombo = combo;

	LLRadioGroup* group;
	group = LLViewerUICtrlFactory::getRadioGroupByName(this, "animation_trigger_type");
	group->setVisible(FALSE);
	group->setCommitCallback(onCommitAnimationTrigger);
	group->setCallbackUserData(this);
	mAnimationRadio = group;

	combo = LLViewerUICtrlFactory::getComboBoxByName(this, "sound_list");
	combo->setVisible(FALSE);
	combo->setCommitCallback(onCommitSound);
	combo->setCallbackUserData(this);
	mSoundCombo = combo;

	edit = LLViewerUICtrlFactory::getLineEditorByName(this, "chat_editor");
	edit->setVisible(FALSE);
	edit->setCommitCallback(onCommitChat);
	//edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mChatEditor = edit;

	check = LLViewerUICtrlFactory::getCheckBoxByName(this, "wait_anim_check");
	check->setVisible(FALSE);
	check->setCommitCallback(onCommitWait);
	check->setCallbackUserData(this);
	mWaitAnimCheck = check;

	check = LLViewerUICtrlFactory::getCheckBoxByName(this, "wait_time_check");
	check->setVisible(FALSE);
	check->setCommitCallback(onCommitWait);
	check->setCallbackUserData(this);
	mWaitTimeCheck = check;

	edit = LLViewerUICtrlFactory::getLineEditorByName(this, "wait_time_editor");
	edit->setEnabled(FALSE);
	edit->setVisible(FALSE);
	edit->setPrevalidate(LLLineEditor::prevalidateFloat);
//	edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCommitCallback(onCommitWaitTime);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mWaitTimeEditor = edit;

	// Buttons at the bottom
	check = LLViewerUICtrlFactory::getCheckBoxByName(this, "active_check");
	check->setCommitCallback(onCommitActive);
	check->setCallbackUserData(this);
	mActiveCheck = check;

	btn = LLViewerUICtrlFactory::getButtonByName(this, "save_btn");
	btn->setClickedCallback(onClickSave);
	btn->setCallbackUserData(this);
	mSaveBtn = btn;

	btn = LLViewerUICtrlFactory::getButtonByName(this, "preview_btn");
	btn->setClickedCallback(onClickPreview);
	btn->setCallbackUserData(this);
	mPreviewBtn = btn;


	// Populate the comboboxes
	addModifiers();
	addKeys();
	addAnimations();
	addSounds();


	const LLInventoryItem* item = getItem();

	if (item) 
	{
		childSetCommitCallback("desc", LLPreview::onText, this);
		childSetText("desc", item->getDescription());
		childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
	}

	return TRUE;
}