Ejemplo n.º 1
0
void EditorFrameHandler::ExitGUI()
{
	MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();
	MainMenuBar->deleteAllItems();
	gui->destroyWidget(MainMenuBar);	
	ObjectsList.Close();
}
Ejemplo n.º 2
0
void EditorFrameHandler::InitGUI()
{
	MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();

	// создание меню
	MainMenuBar = gui->createWidget<MyGUI::MenuBar>("MenuBar", MyGUI::IntCoord(0, 0, gui->getViewWidth(), 28), MyGUI::Align::Top | MyGUI::Align::HStretch, "Overlapped", "LayoutEditor_MenuBar");
	MainMenuBar->addItem("File");
	MainMenuBar->addItem("Options");
	// FIXME менюбар сунуть в лейаут
	//interfaceWidgets.push_back(bar);

	PopupMenuFile = MainMenuBar->getItemMenu(0);
	PopupMenuFile->addItem("Load");
	PopupMenuFile->addItem("Save");
	PopupMenuFile->addItem("Save_as");
	PopupMenuFile->addItem("Clear", false, true);
	PopupMenuFile->addItem("Settings");	
	PopupMenuFile->addItem("Quit");
	
	PopupMenuOptions = MainMenuBar->getItemMenu(1);	
	PopupMenuOptions->addItem("Environment");

	//for (List<Ogre::UTFString>::ListNode *pos = XMLEditorNodes.GetBegin();pos!=NULL;pos=pos->Next)
	ObjectsList.Load();

	std::map<Ogre::UTFString, SEditableDescription>::iterator iPos = EditorNodes.begin(), iEnd = EditorNodes.end();
	for (;iPos!=iEnd;++iPos)
	{
		//PopupMenuWidgets->addItem(iPos->first);
		ObjectsList.AddItem(iPos->first);
	}
	
	MainMenuBar->eventPopupMenuAccept = MyGUI::newDelegate(this, &EditorFrameHandler::NotifyPopupMenuAccept);
}
Ejemplo n.º 3
0
void IntroState::createMyGui()
{
    MyGUI::OgrePlatform *mp = new MyGUI::OgrePlatform();
    mp->initialise(_root->getAutoCreatedWindow(), Ogre::Root::getSingleton().getSceneManager("SceneManager"));
    MyGUI::Gui *mGUI = new MyGUI::Gui();
    mGUI->initialise();
   layout = MyGUI::LayoutManager::getInstance().loadLayout(LAYOUT_INTRO);
  //MyGUI::PointerManager::getInstancePtr()->setVisible(true);
}
Ejemplo n.º 4
0
void EditorFrameHandler::Exit()
{
	CommonDeclarations::GetApplication()->SetCurrentCamera(CommonDeclarations::GetCamera()->GetOgreCamera());
	Ogre::SceneManager *SceneMgr = CommonDeclarations::GetSceneManager();
	SceneMgr->destroyCamera(EditorCamera);
	EditorCamera = NULL;

	ExitGUI();

	MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();
	gui->hidePointer();
}
Ejemplo n.º 5
0
	bool frameStarted(const Ogre::FrameEvent& evt)
	{
		if (mExit)
			return false;
		if (mWindow->isClosed())
			return false;

		mKeyboard->capture();
		mMouse->capture();

		if (mKeyboard->isKeyDown(OIS::KC_A) || mKeyboard->isKeyDown(OIS::KC_LEFT))
			mCamera->moveRelative(Ogre::Vector3(-evt.timeSinceLastFrame*20, 0, 0));

		if (mKeyboard->isKeyDown(OIS::KC_D) || mKeyboard->isKeyDown(OIS::KC_RIGHT))
			mCamera->moveRelative(Ogre::Vector3(evt.timeSinceLastFrame*20, 0, 0));

		if (mKeyboard->isKeyDown(OIS::KC_W) || mKeyboard->isKeyDown(OIS::KC_UP))
			mCamera->moveRelative(Ogre::Vector3(0, 0, -evt.timeSinceLastFrame*20));

		if (mKeyboard->isKeyDown(OIS::KC_S) || mKeyboard->isKeyDown(OIS::KC_DOWN))
			mCamera->moveRelative(Ogre::Vector3(0, 0, evt.timeSinceLastFrame*20));

		mGUI->injectFrameEntered(evt.timeSinceLastFrame);

		return true;
	}
Ejemplo n.º 6
0
void PanelObjectsList::RemoveItem(Ogre::UTFString name)
{
	MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();
	MyGUI::VectorWidgetPtr::iterator iPos = mItemsCheckBox.begin(), iEnd = mItemsCheckBox.end();
	for (;iPos!=iEnd;++iPos)
	{
		if ((*iPos)->getCaption()==name)
		{
			gui->destroyChildWidget(*iPos);
			mItemsCheckBox.erase(iPos);
					
			UpdateItemsView();
			break;
		}
	}	
}
Ejemplo n.º 7
0
bool GUIMessageLayout::Load()
{
	bool res = GUILayout::Load();
	
	MyGUI::ButtonPtr button;

	MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();
	
	button = gui->findWidget<MyGUI::Button>("MessageButtonOK");
	button->eventMouseButtonClick = MyGUI::newDelegate(this, &GUIMessageLayout::mousePressed);

	MyGUI::WidgetPtr widget = Widgets.front();
	
	widget->setPosition(gui->getViewWidth()/2-widget->getWidth()/2,gui->getViewHeight()/2-widget->getHeight()/2);

	return res;
}
Ejemplo n.º 8
0
void GraphicsImpl::handleKeyEvents(const DataContainer& data)
{
	InputKeyboardEvent ev = boost::any_cast<InputKeyboardEvent>(data.data);

	if (ev.action == BUTTON_PRESSED) {
		gui->injectKeyPress((MyGUI::KeyCode::Enum) ev.type);

		if (ev.type == KEY_W) {
			movementVector.z = -1;
		}

		else if (ev.type == KEY_S) {
			movementVector.z = 1;
		}

		else if (ev.type == KEY_A) {
			movementVector.x = -1;
		}

		else if (ev.type == KEY_D) {
			movementVector.x = 1;
		}
	}

	else {
		gui->injectKeyRelease((MyGUI::KeyCode::Enum) ev.type);

		if (ev.type == KEY_W) {
			movementVector.z = 0;
		}

		else if (ev.type == KEY_S) {
			movementVector.z = 0;
		}

		else if (ev.type == KEY_A) {
			movementVector.x = 0;
		}

		else if (ev.type == KEY_D) {
			movementVector.x = 0;
		}
	}
}
Ejemplo n.º 9
0
	bool mouseMoved(const OIS::MouseEvent &arg)
	{
		mCameraAngleH -= Ogre::Degree((Ogre::Real)arg.state.X.rel);
		mCameraAngleV -= Ogre::Degree((Ogre::Real)arg.state.Y.rel);
		mCamera->setOrientation(Ogre::Quaternion::IDENTITY);
		mCamera->yaw(mCameraAngleH*0.1);
		mCamera->pitch(mCameraAngleV*0.1);

		mGUI->injectMouseMove(arg);
		return true;
	}
Ejemplo n.º 10
0
void GraphicsImpl::threadWillStop()
{
	delete caelumSystem;
	gui->shutdown();
	delete gui;
	delete listener;
	//Ogre::WindowEventUtilities::removeWindowEventListener(window, this);
	//windowClosed(window);

	root->shutdown();
	//delete root;
	boost::this_thread::sleep(boost::posix_time::milliseconds(100));		// Wait 1/100 s
}
Ejemplo n.º 11
0
	bool keyPressed(const OIS::KeyEvent &arg)
	{
		switch (arg.key) {
		case OIS::KC_ESCAPE:
			mExit = true;
			break;
		default:
			break;
		}

		mGUI->injectKeyPress(arg);
		return true;
	}
Ejemplo n.º 12
0
void GraphicsImpl::handleMouseEvents(const DataContainer& data)
{
	InputMouseEvent ev = boost::any_cast<InputMouseEvent>(data.data);
	static bool mouseButtonPressed = false;

	gui->injectMouseMove(ev.mouseX, ev.mouseY, 0);
	camera->yaw(Ogre::Degree(-ev.mouseDeltaX * 0.13));
	camera->pitch(Ogre::Degree(-ev.mouseDeltaY * 0.13));


	
		MyGUI::MouseButton id;

		if (ev.type == BUTTON_MOUSE_LEFT) {
			id = MyGUI::MouseButton::Left;
		}

		else if (ev.type == BUTTON_MOUSE_RIGHT) {
			id = MyGUI::MouseButton::Right;
		}

		else {
			id = MyGUI::MouseButton::Middle;
		}


		if (ev.action == BUTTON_PRESSED) {
			mouseButtonPressed = true;
			gui->injectMousePress(ev.mouseX, ev.mouseY, id);
		}

		else {
			mouseButtonPressed = false;
			gui->injectMouseRelease(ev.mouseX, ev.mouseY, id);
		}
	
}
Ejemplo n.º 13
0
bool GraphicsImpl::doStep()
{
	if (newWorld) {
		boost::mutex::scoped_lock lock(worldMutex);
		std::swap(frontWorld, backWorld);
		newWorld = false;
	}

	gui->injectFrameEntered(timeSinceLastFrame());

	moveScale = timeSinceLastFrame() * 100;
	camera->moveRelative(movementVector * moveScale);
	updatePositions();
	Ogre::WindowEventUtilities::messagePump();
	caelumSystem->notifyCameraChanged(camera);
	return root->renderOneFrame();
}
Ejemplo n.º 14
0
void GraphicsImpl::setupGUI()
{
	MyGUI::Gui * mGUI;
	MyGUI::OgrePlatform* platform = new MyGUI::OgrePlatform();
	platform->initialise(window, sceneMgr);
	gui = new MyGUI::Gui();
	gui->initialise();

	mainGuiWidget = gui->createWidgetReal<MyGUI::Widget>("Default", 0.0, 0.0, 1.0, 1.0, MyGUI::Align::Default, "Main");

	MyGUI::ButtonPtr button = mainGuiWidget->createWidgetReal<MyGUI::Button>("Button", 0.005, 0.008, 0.156, 0.05, MyGUI::Align::Default, "exit");
	button->setCaption("exit");
	// set callback
	button->eventMouseButtonClick = MyGUI::newDelegate(this, &GraphicsImpl::guiCallback);

	button = mainGuiWidget->createWidgetReal<MyGUI::Button>("Button", 0.182, 0.008, 0.156, 0.05, MyGUI::Align::Default, "do");
	button->setCaption("do something");
	// set callback
	button->eventMouseButtonClick = MyGUI::newDelegate(this, &GraphicsImpl::guiCallback);
}
Ejemplo n.º 15
0
void EditorFrameHandler::Init()
{
	Ogre::SceneManager *scene_manager = CommonDeclarations::GetSceneManager();
	EditorCamera = scene_manager->createCamera("EditorCamera");
	EditorCamera->setNearClipDistance(5);		
	EditorCamera->setFarClipDistance(0);

	EditorCamera->setPosition(CommonDeclarations::GetCamera()->GetOgreCamera()->getWorldPosition());

	CommonDeclarations::GetApplication()->SetCurrentCamera(EditorCamera);

	/*CommonDeclarations::ObjectsPool *objects = CommonDeclarations::GetEditableObjects();
	for (CommonDeclarations::ObjectsPool::ListNode *pos = objects->GetBegin();pos!=NULL;pos=pos->Next)
	{		
		SEditableObject obj;
		obj.Object = pos->Value;
		IScenable *scen = pos->Value->GetScenable();
		if (scen)
		{
			obj.EditNode = NULL;
			obj.EditEntity = NULL;
			ICollidable *collid = pos->Value->GetCollidable();
			if (collid)
			{
				obj.CollisionModel = collid->GetCollisionModel();
			} else
			{				
				const char *modelname = scen->GetModelName();
				if (NULL == modelname)
					modelname = AAUtilities::StringCopy("cube.mesh");
				obj.CollisionModel = GetCollisionModel(modelname);
			}				
		} else
		{
			obj.EditNode = scene_manager->getRootSceneNode()->createChildSceneNode();	
			char *buffer = CommonDeclarations::GenGUID();			
			obj.EditEntity = scene_manager->createEntity(buffer, "cube.mesh");					
			delete [] buffer;

			obj.EditNode->attachObject(obj.EditEntity);

			obj.CollisionModel = GetCollisionModel("cube.mesh");
		}
		EditableObjects.PushBack(obj);		
	}
	delete objects;*/

	//
	CommonDeclarations::ObjectsPool *objects = CommonDeclarations::GetEditableObjects();
	const char *str;
	TiXmlElement *node = 0, *nodes, *env;
	env = SceneRootElement->FirstChildElement("environment");	
	if (env)
	{
		node = env->FirstChildElement("skyBox");	
		if (node)
		{			
			SEditableDescription descr;
				
			descr.EditNode = NULL;
			descr.EditElement = node;
			EditorNodes.insert(std::make_pair("SkyBox", descr));
		}
	}
	
	nodes = SceneRootElement->FirstChildElement("nodes");	
	if (nodes)
	{
		node = nodes->FirstChildElement("node");	
		
		Ogre::Node::ChildNodeIterator iFirst = scene_manager->getRootSceneNode()->getChildIterator(), iPos = iFirst;
		
		while (node)
		{
			str = node->Attribute("name");
			SEditableDescription descr;
			Ogre::Node *t = NULL;
			iPos = iFirst;
			while (iPos.hasMoreElements()) 
			{
				t = iPos.getNext();
				if (t->getName()==str)
				{
					descr.EditNode = t;
					break;
				}
			}
			
			descr.EditElement = node;
			EditorNodes.insert(std::make_pair(str, descr));
			
			node = node->NextSiblingElement("node");
		}
	}
	delete objects;
	//

	MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();
	OIS::Mouse *mouse = EditorFrameListener::GetInstance()->GetMouse();

	InitGUI();

	const OIS::MouseState &ms = mouse->getMouseState();
	int x=ms.width/2,
		y=ms.height/2;
	mouse->setMousePosition(x,y);
    gui->setPointerPosition(x, y);	
	gui->showPointer();
}
Ejemplo n.º 16
0
    bool initialise()
    {
		mRoot = new Ogre::Root(PLUGINS_CFG, OGRE_CFG, OGRE_LOG);

		if (!mRoot->restoreConfig())
			if (!mRoot->showConfigDialog())
				return false;

		initResources();

        mWindow = mRoot->initialise(true, "CS Clone Editor v0.0");
        Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

		mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
		mSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));
		mCamera = mSceneMgr->createCamera("camera");
        mWindow->addViewport(mCamera);
        mCamera->setAutoAspectRatio(true);
        mCamera->setNearClipDistance(0.1);
        mCamera->setFarClipDistance(10000);
        mCamera->setPosition(10, 10, 10);
//        mCamera->lookAt(0, 0, 0);

        mRoot->addFrameListener(this);

		Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//Initializing OIS
		Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* OIS Initialising");

		OIS::ParamList pl;
		size_t windowHnd = 0;
		mWindow->getCustomAttribute("WINDOW", &windowHnd);
		pl.insert(std::make_pair(std::string("WINDOW"), Ogre::StringConverter::toString(windowHnd)));

#if OGRE_DEBUG_MODE == 1
	#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
		#define NO_EXCLUSIVE_INPUT
	#endif
#endif

#ifdef NO_EXCLUSIVE_INPUT
	#if defined OIS_WIN32_PLATFORM
		pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
		pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
		pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
		pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
	#elif defined OIS_LINUX_PLATFORM
		pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
		pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
		pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
		pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
	#endif
#endif
		mInputManager = OIS::InputManager::createInputSystem(pl);

		mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
		mKeyboard->setEventCallback(this);
		mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
		mMouse->setEventCallback(this);

		windowResized(mWindow);
//Initialising GUI
		Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* MyGUI Initialising");
		mGUI = new MyGUI::Gui;
		mGUI->initialise(mWindow);
		mGUI->load("editor.layout");

		mMenuBar = mGUI->createWidget<MyGUI::MenuBar>("MenuBar",
			MyGUI::IntCoord(0, 0, mGUI->getViewWidth(), 28),
			MyGUI::ALIGN_TOP | MyGUI::ALIGN_HSTRETCH, "Overlapped");

		mMenuBar->addItem("File");
		mPopupMenuFile = mMenuBar->getItemMenu(0);
		mPopupMenuFile->addItem("New");
		mPopupMenuFile->addItem("Open ...");
		mPopupMenuFile->addItem("Save");
		mPopupMenuFile->addItem("Save as ...", false, true);
		mPopupMenuFile->addItem("Settings", false, true);
		mPopupMenuFile->addItem("Quit");

		mMenuBar->addItem("Help");
		mPopupMenuHelp = mMenuBar->getItemMenu(1);
		mPopupMenuHelp->addItem("Help");
		mPopupMenuHelp->addItem("About ...");

		return (true);
    }
Ejemplo n.º 17
0
	bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
	{
		mGUI->injectMouseRelease(arg, id);
		return true;
	}
Ejemplo n.º 18
0
	bool keyReleased(const OIS::KeyEvent &arg)
	{
		mGUI->injectKeyRelease(arg);
		return true;
	}