コード例 #1
0
ファイル: GUIMenu.cpp プロジェクト: KinaMarie/rigs-of-rods
GUI_MainMenu::GUI_MainMenu(GuiManagerInterface* gui_manager_interface) :
	  m_menu_width(800)
	, m_menu_height(20)
	, m_vehicle_list_needs_update(false)
	, m_gui_manager_interface(gui_manager_interface)
{
	setSingleton(this);
	pthread_mutex_init(&m_update_lock, NULL);

	/* -------------------------------------------------------------------------------- */
	/* MENU BAR */

	m_menubar_widget = MyGUI::Gui::getInstance().createWidget<MyGUI::MenuBar>("MenuBar", 0, 0, m_menu_width, m_menu_height,  MyGUI::Align::HStretch | MyGUI::Align::Top, "Main");
	m_menubar_widget->setCoord(0, 0, m_menu_width, m_menu_height);
	
	/* -------------------------------------------------------------------------------- */
	/* SIMULATION POPUP MENU */

	MyGUI::MenuItemPtr mi = m_menubar_widget->createWidget<MyGUI::MenuItem>("MenuBarButton", 0, 0, 60, m_menu_height,  MyGUI::Align::Default);
	MyGUI::PopupMenuPtr p = mi->createWidget<MyGUI::PopupMenu>(MyGUI::WidgetStyle::Popup, "PopupMenu",MyGUI::IntCoord(0,0,88,68),MyGUI::Align::Default, "Popup");
	mi->setItemType(MyGUI::MenuItemType::Popup);
	mi->setCaption(_L("Simulation"));
	p->setPopupAccept(true);
	
	p->addItem(_L("Get new vehicle"),                 MyGUI::MenuItemType::Normal);
	p->addItem(_L("Show vehicle description"),		  MyGUI::MenuItemType::Normal);
	p->addItem(_L("Reload current vehicle"),          MyGUI::MenuItemType::Normal);
	p->addItem(_L("Remove current vehicle"),          MyGUI::MenuItemType::Normal);

	if (!BSETTING("Network enable", false))
	{
		p->addItem(_L("Activate all vehicles"), MyGUI::MenuItemType::Normal);
		p->addItem(_L("Activated vehicles never sleep"), MyGUI::MenuItemType::Normal);
		p->addItem(_L("Send all vehicles to sleep"), MyGUI::MenuItemType::Normal);
	}
	p->addItem("-",                                   MyGUI::MenuItemType::Separator);

	/*p->addItem(_L("Save Scenery"),                    MyGUI::MenuItemType::Normal);
	p->addItem(_L("Load Scenery"),                    MyGUI::MenuItemType::Normal);
	p->addItem("-",                                   MyGUI::MenuItemType::Separator);*/ //Disabled for the moment as far as i know -max98

	if (!BSETTING("Network enable", false))
		p->addItem(_L("Back to menu"),					  MyGUI::MenuItemType::Normal);

	p->addItem(_L("Exit"),                            MyGUI::MenuItemType::Normal);
	m_popup_menus.push_back(p);

	/* -------------------------------------------------------------------------------- */
	/* VEHICLES POPUP MENU */

	mi = m_menubar_widget->createWidget<MyGUI::MenuItem>("MenuBarButton", 0, 0, 60, m_menu_height,  MyGUI::Align::Default);
	m_vehicles_menu_widget = mi->createWidget<MyGUI::PopupMenu>(MyGUI::WidgetStyle::Popup, "PopupMenu", MyGUI::IntCoord(0,0,88,68),MyGUI::Align::Default, "Popup");
	p = m_vehicles_menu_widget;
	mi->setItemType(MyGUI::MenuItemType::Popup);
	mi->setCaption("Vehicles");
	m_popup_menus.push_back(p);

	/* -------------------------------------------------------------------------------- */
	/* EDITOR POPUP MENU */

	mi = m_menubar_widget->createWidget<MyGUI::MenuItem>("MenuBarButton", 0, 0, 60, m_menu_height,  MyGUI::Align::Default);
	p = mi->createWidget<MyGUI::PopupMenu>(MyGUI::WidgetStyle::Popup, "PopupMenu",MyGUI::IntCoord(0,0,88,68),MyGUI::Align::Default, "Popup");
	mi->setItemType(MyGUI::MenuItemType::Popup);
	mi->setCaption("Editor");
	
	p->addItem(_L("Open rig editor"), MyGUI::MenuItemType::Normal, "rig-editor-enter");
	m_popup_menus.push_back(p);

	/* -------------------------------------------------------------------------------- */
	/* WINDOWS POPUP MENU */

	mi = m_menubar_widget->createWidget<MyGUI::MenuItem>("MenuBarButton", 0, 0, 60, m_menu_height,  MyGUI::Align::Default);
	p = mi->createWidget<MyGUI::PopupMenu>(MyGUI::WidgetStyle::Popup, "PopupMenu",MyGUI::IntCoord(0,0,88,68),MyGUI::Align::Default, "Popup");
	mi->setItemType(MyGUI::MenuItemType::Popup);
	mi->setCaption("Windows");
	
	p->addItem(_L("Friction Settings"),  MyGUI::MenuItemType::Normal, "frictiongui");
	p->addItem(_L("Show Console"),       MyGUI::MenuItemType::Normal, "showConsole");
	p->addItem(_L("Texture Tool"),       MyGUI::MenuItemType::Normal, "texturetool");
	p->addItem(_L("Debug Options"),		 MyGUI::MenuItemType::Normal, "debugoptions");
	m_popup_menus.push_back(p);

	/* -------------------------------------------------------------------------------- */
	/* DEBUG POPUP MENU */

	mi = m_menubar_widget->createWidget<MyGUI::MenuItem>("MenuBarButton", 0, 0, 60, m_menu_height,  MyGUI::Align::Default);
	p = mi->createWidget<MyGUI::PopupMenu>(MyGUI::WidgetStyle::Popup, "PopupMenu",MyGUI::IntCoord(0,0,88,68),MyGUI::Align::Default, "Popup");
	mi->setItemType(MyGUI::MenuItemType::Popup);
	mi->setCaption("Debug");
	p->addItem(_L("no visual debug"),         MyGUI::MenuItemType::Normal, "debug-none");
	p->addItem(_L("show Node numbers"),       MyGUI::MenuItemType::Normal, "debug-node-numbers");
	p->addItem(_L("show Beam numbers"),       MyGUI::MenuItemType::Normal, "debug-beam-numbers");
	p->addItem(_L("show Node&Beam numbers"),  MyGUI::MenuItemType::Normal, "debug-nodenbeam-numbers");
	p->addItem(_L("show Node mass"),          MyGUI::MenuItemType::Normal, "debug-node-mass");
	p->addItem(_L("show Node locked"),        MyGUI::MenuItemType::Normal, "debug-node-locked");
	p->addItem(_L("show Beam compression"),   MyGUI::MenuItemType::Normal, "debug-beam-compression");
	p->addItem(_L("show Beam broken"),        MyGUI::MenuItemType::Normal, "debug-beam-broken");
	p->addItem(_L("show Beam stress"),        MyGUI::MenuItemType::Normal, "debug-beam-stress");
	p->addItem(_L("show Beam strength"),      MyGUI::MenuItemType::Normal, "debug-beam-strength");
	p->addItem(_L("show Beam hydros"),        MyGUI::MenuItemType::Normal, "debug-beam-hydros");
	p->addItem(_L("show Beam commands"),      MyGUI::MenuItemType::Normal, "debug-beam-commands");
	m_popup_menus.push_back(p);

	/* -------------------------------------------------------------------------------- */
	/* RIG LOADING REPORT WINDOW */

	mi = m_menubar_widget->createWidget<MyGUI::MenuItem>("MenuBarButton", 0, 0, 60, m_menu_height,  MyGUI::Align::Default);
	mi->setItemType(MyGUI::MenuItemType::Popup);
	mi->setCaption("Spawner log");
	mi->eventMouseButtonClick += MyGUI::newDelegate( this, &GUI_MainMenu::MenubarShowSpawnerReportButtonClicked);

	/* -------------------------------------------------------------------------------- */
	/* MENU BAR POSITION */

	MyGUI::IntSize s = mi->getTextSize();
	m_menu_height = s.height + 6;
	m_menubar_widget->setCoord(0, 0, m_menu_width, m_menu_height);

	/* -------------------------------------------------------------------------------- */

	// event callbacks
	m_menubar_widget->eventMenuCtrlAccept += MyGUI::newDelegate(this, &GUI_MainMenu::onMenuBtn);

	// initial mouse position somewhere so the menu is hidden
	updatePositionUponMousePosition(500, 500);
}
コード例 #2
0
ファイル: editor.cpp プロジェクト: ItzFluffy/csclone
    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);
    }