예제 #1
0
void LLChatBar::onCommitGesture(LLUICtrl* ctrl)
{
	LLCtrlListInterface* gestures = mGestureCombo ? mGestureCombo->getListInterface() : NULL;
	if (gestures)
	{
		S32 index = gestures->getFirstSelectedIndex();
		if (index == 0)
		{
			return;
		}
		const std::string& trigger = gestures->getSelectedValue().asString();

		// pretend the user chatted the trigger string, to invoke
		// substitution and logging.
		std::string text(trigger);
		std::string revised_text;
		LLGestureMgr::instance().triggerAndReviseString(text, &revised_text);

		revised_text = utf8str_trim(revised_text);
		if (!revised_text.empty())
		{
			// Don't play nodding animation
			sendChatFromViewer(revised_text, CHAT_TYPE_NORMAL, FALSE);
		}
	}
	mGestureLabelTimer.start();
	if (mGestureCombo != NULL)
	{
		// free focus back to chat bar
		mGestureCombo->setFocus(FALSE);
	}
}
void LLGestureComboList::onCommitGesture()
{
	LLCtrlListInterface* gestures = getListInterface();
	if (gestures)
	{
		S32 sel_index = gestures->getFirstSelectedIndex();
		if (sel_index == 0)
		{
			return;
		}

		S32 index = gestures->getSelectedValue().asInteger();

		if (mViewAllItemIndex == index)
		{
			// The same behavior as Ctrl+G. EXT-823
			LLFloaterReg::toggleInstance("gestures");
			gestures->selectFirstItem();
			return;
		}

		if (mGetMoreItemIndex == index)
		{
			LLWeb::loadURLExternal(gSavedSettings.getString("GesturesMarketplaceURL"));
			return;
		}

		if (index<0 || index >= (S32)mGestures.size())
		{
			llwarns << "out of range gesture index" << llendl;
		}
		else
		{
			LLMultiGesture* gesture = mGestures.at(index);
			if(gesture)
			{
				LLGestureMgr::instance().playGesture(gesture);
				if(!gesture->mReplaceText.empty())
				{
					LLNearbyChatBar::sendChatFromViewer(gesture->mReplaceText, CHAT_TYPE_NORMAL, FALSE);
				}
			}
		}
	}
}
void LLGestureComboList::refreshGestures()
{
	//store current selection so we can maintain it
	LLSD cur_gesture = getValue();
	
	mList->selectFirstItem();
	mList->clearRows();
	mGestures.clear();

	LLGestureMgr::item_map_t::const_iterator it;
	const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures();
	LLSD::Integer idx(0);
	for (it = active_gestures.begin(); it != active_gestures.end(); ++it)
	{
		LLMultiGesture* gesture = (*it).second;
		if (gesture)
		{
			mList->addSimpleElement(gesture->mName, ADD_BOTTOM, LLSD(idx));
			mGestures.push_back(gesture);
			idx++;
		}
	}

	sortByName();

	// store indices for Get More and View All items (idx is the index followed by the last added Gesture)
	if (mShowGetMore)
	{
		mGetMoreItemIndex = idx;
		mList->addSimpleElement(LLTrans::getString("GetMoreGestures"), ADD_BOTTOM, LLSD(mGetMoreItemIndex));
	}
	if (mShowViewAll)
	{
		mViewAllItemIndex = idx + 1;
		mList->addSimpleElement(LLTrans::getString("ViewAllGestures"), ADD_BOTTOM, LLSD(mViewAllItemIndex));
	}

	// Insert label after sorting, at top, with separator below it
	mList->addSeparator(ADD_TOP);	
	mList->addSimpleElement(mLabel, ADD_TOP);

	if (cur_gesture.isDefined())
	{ 
		mList->selectByValue(cur_gesture);

	}
	else
	{
		mList->selectFirstItem();
	}

	LLCtrlListInterface* gestures = getListInterface();
	LLMultiGesture* gesture = NULL;
	
	if (gestures)
	{
		S32 sel_index = gestures->getFirstSelectedIndex();
		if (sel_index != 0)
		{
			S32 index = gestures->getSelectedValue().asInteger();
			if (index<0 || index >= (S32)mGestures.size())
			{
				llwarns << "out of range gesture access" << llendl;
			}
			else
			{
				gesture = mGestures.at(index);
			}
		}
	}
	
	if(gesture && LLGestureMgr::instance().isGesturePlaying(gesture))
	{
		return;
	}
	
	mButton->setLabel(mLabel);
}
// static
void LLWindlightRemoteCtrl::onCommitPreset(LLUICtrl* ctrl, void* data)
{
	LLWindlightRemoteCtrl* self = (LLWindlightRemoteCtrl*)data;

	LLComboBox*	presetsCombo = self->getChild<LLComboBox>("Presets");

	LLCtrlListInterface* presets = presetsCombo ? presetsCombo->getListInterface() : NULL;
	if (presets)
	{
		S32 index = presets->getFirstSelectedIndex();
		if (index < 0)
		{
			// Open Advanced Sky
			LLFloaterWindLight::show();
			return;
		}

		// check for World menu options; if none, apply preset
		std::string selected = presetsCombo->getSelectedValue().asString();

		/*if (selected == self->getString("atmosphere"))
		{
			if (!LLFloaterWindLight::instance()->getVisible())
			{
				LLFloaterWindLight::show();
			}
			LLFloaterWindLight::instance()->selectTab("Atmosphere");
		}
		else if (selected == self->getString("lighting"))
		{
			if (!LLFloaterWindLight::instance()->getVisible())
			{
				LLFloaterWindLight::show();
			}
			LLFloaterWindLight::instance()->selectTab("Lighting");
		}
		else if (selected == self->getString("clouds"))
		{
			if (!LLFloaterWindLight::instance()->getVisible())
			{
				LLFloaterWindLight::show();
			}
			LLFloaterWindLight::instance()->selectTab("Clouds");
		}
		else if (selected == self->getString("advanced_water"))
		{
			LLFloaterWater::show();
		}
		else*/ if (selected == self->getString("sunrise"))
		{
			// set the value, turn off animation
			LLWLParamManager::instance()->mAnimator.setDayTime(0.25);
			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;

			// then call update once
			LLWLParamManager::instance()->mAnimator.update(
				LLWLParamManager::instance()->mCurParams);
		}
		else if (selected == self->getString("noon"))
		{
			// set the value, turn off animation
			LLWLParamManager::instance()->mAnimator.setDayTime(0.567);
			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;

			// then call update once
			LLWLParamManager::instance()->mAnimator.update(
				LLWLParamManager::instance()->mCurParams);
		}
		else if (selected == self->getString("sunset"))
		{
			// set the value, turn off animation
			LLWLParamManager::instance()->mAnimator.setDayTime(0.75);
			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;

			// then call update once
			LLWLParamManager::instance()->mAnimator.update(
				LLWLParamManager::instance()->mCurParams);
		}
		else if (selected == self->getString("midnight"))
		{
			// set the value, turn off animation
			LLWLParamManager::instance()->mAnimator.setDayTime(0.0);
			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;

			// then call update once
			LLWLParamManager::instance()->mAnimator.update(
				LLWLParamManager::instance()->mCurParams);
		}
		else if (selected == self->getString("revert_region"))
		{
			LLWLParamManager::instance()->mAnimator.mIsRunning = true;
			LLWLParamManager::instance()->mAnimator.mUseLindenTime = true;	
		}
		else
		{
			// Apply preset
			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
			LLWLParamManager::instance()->loadPreset(selected, true);
		}
	}
}