Esempio n. 1
0
bool TabNavigation::OnEventKeyDown(const CEGUI::EventArgs& e)
{
	const CEGUI::KeyEventArgs& args = static_cast<const CEGUI::KeyEventArgs&>(e);
	if (args.scancode == CEGUI::Key::Tab) // Tab or Shift+Tab
	{
		WidgetList::iterator itCurrent = Containers::find(mTabOrder.begin(), mTabOrder.end(), args.window);
		OC_ASSERT(itCurrent != mTabOrder.end());
		WidgetList::iterator itFocus = itCurrent;
		CEGUI::Window* newWidget = 0;
		do
		{
			if (args.sysKeys & CEGUI::Shift)
			{
				// Set previous
				if (itFocus == mTabOrder.begin())
					itFocus = mTabOrder.end();
				--itFocus;
			}
			else
			{
				// Set next
				++itFocus;
				if (itFocus == mTabOrder.end())
					itFocus = mTabOrder.begin();
			}
			newWidget = *itFocus;
		}
		while ((!newWidget->isVisible() || newWidget->isDisabled() || newWidget->getProperty("ReadOnly") == "True" ) && itFocus != itCurrent);
		newWidget->activate();

		// Make sure active widget will be visible
		if (mScrollablePane)
		{
			CEGUI::Window* w = newWidget;
			CEGUI::Vector2 widgetOffset(0, 0);
			do
			{
				widgetOffset += w->getPosition().asAbsolute(w->getParentPixelSize());
				w = w->getParent();
			}
			while (w != mScrollablePane && w != 0);

			float32 scrollViewTop = mScrollablePane->getContentPaneArea().getSize().d_height * mScrollablePane->getVerticalScrollPosition();
			float32 scrollViewBottom = scrollViewTop + mScrollablePane->getClipRect().getHeight();
			
			if (widgetOffset.d_y < scrollViewTop || widgetOffset.d_y + newWidget->getPixelSize().d_height > scrollViewBottom)
			{
				// We need to scroll
				mScrollablePane->setVerticalScrollPosition(widgetOffset.d_y / mScrollablePane->getContentPaneArea().getSize().d_height);
			}
		}

		return true;
	}
	return false;
}
Esempio n. 2
0
// 子窗口是否已经打开了
BOOL CUIWindowItem::IsChildWindowShow(LPCTSTR szUIName) const
{
	CEGUI::String strName(szUIName);

	try
	{
		CEGUI::Window* pChild = CEGUI::WindowManager::getSingleton().getWindow(strName);
		if( pChild )
			return pChild->isVisible();
	}
	catch(...)
	{
		return FALSE;
	}

	return FALSE;
}
bool GameInputHandler::keyPressed(const OIS::KeyEvent &evt)
{
	CEGUIInputHandler::keyPressed(evt);
	
	handleCommonKeyboardEvents(evt);
	
	if (game.getSubState() != SUBST_EDITOR)
		return true;
	
	OIS::KeyCode ch = evt.key;

	if (ch == OIS::KC_P)
	{
		// Switch to player mode
		game.createPlayer(camera->getDerivedPosition());
	}
	else if (ch == OIS::KC_I)
	{
		// Blend interface in/out
		CEGUI::Window* guiPage = windowManager.getPage("Editor");
		if (guiPage->isVisible())
			guiPage->hide();
		else
			guiPage->show();
	}
	else if (ch == OIS::KC_M)
	{
		// Output camera position and orientation to log
		/*string str = "INFO:   position=\"" + StringConverter::toString(game.cameraNode->getPosition()) + "\"" +
					" yawOrientation=\"" + StringConverter::toString(game.cameraYawNode->getOrientation()) + "\"" +
					" pitchOrientation=\"" + StringConverter::toString(game.cameraPitchNode->getOrientation()) + "\"";
		*/
		string str = "INFO:   position=\"" + StringConverter::toString(game.cameraNode->getPosition()) + "\"" +
		" yaw=\"" + StringConverter::toString(game.cameraYawNode->getOrientation().getYaw(false)) + "\"" +
		" pitch=\"" + StringConverter::toString(game.cameraPitchNode->getOrientation().getPitch(false)) + "\"" +
		" roll=\"" + StringConverter::toString(game.cameraRollNode->getOrientation().getRoll(false)) + "\"";
		
		LogManager::getSingleton().logMessage(str.c_str(), LML_CRITICAL);
	}
	else if (ch == OIS::KC_E)
	{
		// Place objects
		game.spawnObject(CEGUI::EventArgs());
	}
	else if (evt.key == OIS::KC_O)
	{
		// Toggle polygon mode
		camera->setPolygonMode((PolygonMode)((camera->getPolygonMode() % 3) + 1));
		if (camera->getPolygonMode() == PM_SOLID)
			vp->setClearEveryFrame(true, FBT_DEPTH);
		else
			vp->setClearEveryFrame(true, FBT_COLOUR | FBT_DEPTH);
	}
	
	if (objectManager.getEditObjects())
	{
		if (ch == OIS::KC_G)
			objectManager.setEditMode(EDITMODE_GRAB);
		else if (ch == OIS::KC_R)
			objectManager.setEditMode(EDITMODE_ROTATE);
		else if (ch == OIS::KC_T)
			objectManager.setEditMode(EDITMODE_SCALE);
		else if (ch == OIS::KC_X)
			objectManager.setEditDirection(Vector3(1, 0, 0));
		else if (ch == OIS::KC_Y)
			objectManager.setEditDirection(Vector3(0, 1, 0));
		else if (ch == OIS::KC_Z)
			objectManager.setEditDirection(Vector3(0, 0, 1));
	}

	return true;
}
Esempio n. 4
0
bool ClientGame::OnEscape(const CEGUI::EventArgs& args)
{
    CEGUI::Window* inGameMenu = GetWindow("InGameMenu");
    inGameMenu->setVisible(!inGameMenu->isVisible());
    return true;
}