bool application::frameRenderingQueued (Ogre::FrameEvent const& e)
{
    if (wnd->isClosed()) return false;
    if (shutdown)        return false;

    kbd   -> capture();
    mouse -> capture();

    tray_mgr->frameRenderingQueued(e);

    if (!tray_mgr->isDialogVisible())
        cameraman->frameRenderingQueued(e);

    return true;
}
bool application::mouseReleased (OIS::MouseEvent const& arg, OIS::MouseButtonID id)
{
    if (tray_mgr->injectMouseUp (arg, id))
        return true;

    cameraman->injectMouseUp (arg, id);
    return true;
}
bool application::mouseMoved (OIS::MouseEvent const& arg)
{
    if (tray_mgr->injectMouseMove(arg))
        return true;

    cameraman->injectMouseMove(arg);
    return true;
}
void application::create_frame_listener()
{
    Ogre::LogManager::getSingletonPtr() -> logMessage("Initializing OIS");
    OIS::ParamList pl;
    size_t wndhnd = 0;
    std::ostringstream wndhndstr;

    wnd->getCustomAttribute ("WINDOW", &wndhnd);
    wndhndstr << wndhnd;
    pl.insert (std::make_pair (std::string {"WINDOW"}, wndhndstr.str()));

    input = OIS::InputManager::createInputSystem(pl);

    kbd   = static_cast<OIS::Keyboard*> (input->createInputObject (OIS::OISKeyboard, true));
    mouse = static_cast<OIS::Mouse*>    (input->createInputObject (OIS::OISMouse,    true));

    mouse -> setEventCallback(this);
    kbd   -> setEventCallback(this);

    windowResized(wnd);

    Ogre::WindowEventUtilities::addWindowEventListener (wnd, this);

    OgreBites::InputContext inctx;
    inctx.mMouse    = mouse;
    inctx.mKeyboard = kbd;
    tray_mgr = new OgreBites::SdkTrayManager ("InterfaceName", wnd, inctx, this);
    tray_mgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    tray_mgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    tray_mgr->hideCursor();

    Ogre::StringVector items;
    items.push_back("cam.pX");
    items.push_back("cam.pY");
    items.push_back("cam.pZ");
    items.push_back("");
    items.push_back("cam.oW");
    items.push_back("cam.oX");
    items.push_back("cam.oY");
    items.push_back("cam.oZ");
    items.push_back("");
    items.push_back("Filtering");
    items.push_back("Poly Mode");

    root->addFrameListener(this);
}
bool application::keyPressed (OIS::KeyEvent const& arg)
{
    if (tray_mgr->isDialogVisible()) return true;

    if (arg.key == OIS::KC_F)
    {
        tray_mgr->toggleAdvancedFrameStats();
    }
    else if (arg.key == OIS::KC_R)
    {
        Ogre::PolygonMode pm;

        switch (cam->getPolygonMode())
        {
        case Ogre::PM_SOLID:
            pm = Ogre::PM_WIREFRAME;
            break;

        case Ogre::PM_WIREFRAME:
            pm = Ogre::PM_POINTS;
            break;

        default:
            pm = Ogre::PM_SOLID;
            break;
        }

        cam->setPolygonMode(pm);
    }
    else if (arg.key == OIS::KC_F5)
    {
        Ogre::TextureManager::getSingleton().reloadAll();
    }
    else if (arg.key == OIS::KC_SYSRQ)
    {
        wnd->writeContentsToTimestampedFile ("screenshot", ".png");
    }
    else if (arg.key == OIS::KC_ESCAPE)
    {
        shutdown = true;
    }

    cameraman->injectKeyDown(arg);
    return true;
}
Esempio n. 6
0
	void GameManager::setupResources(std::string inPath) {

		// Load resource paths from config file
		ConfigFile cf;
		cf.load( inPath );

		// Go through all settings in the file
		ConfigFile::SectionIterator itSection = cf.getSectionIterator();

		String sSection, sType, sArch;
		while( itSection.hasMoreElements() ) {
		    sSection = itSection.peekNextKey();

		    ConfigFile::SettingsMultiMap *mapSettings = itSection.getNext();
		    ConfigFile::SettingsMultiMap::iterator itSetting = mapSettings->begin();
		    while( itSetting != mapSettings->end() ) {
		        sType = itSetting->first;
		        sArch = itSetting->second;
				    ResourceGroupManager::getSingleton().addResourceLocation( sArch, sType, sSection);
		        ++itSetting;
		    }
		}
		// Initialise resources
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
		OgreBites::SdkTrayManager *mTrayMgr =
		  new OgreBites::SdkTrayManager(HAX_APP_NAME_STR + "/Loader", mRenderWindow, InputManager::getSingletonPtr()->getMouse(), 0);
		//mTrayMgr->showAll();
		mTrayMgr->showLoadingBar(1,1, 1);
		//ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
		ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Scripts");
		mTrayMgr->hideLoadingBar();
		delete mTrayMgr;

    // TODO: when do we clean these up?
		//mRenderWindow->removeViewport(-1);
		//mRoot->getSceneManager("LoadingScene")->destroyCamera("LoadingCamera");
		//mRoot->destroySceneManager(mRoot->getSceneManager("LoadingScene"));
	}
Esempio n. 7
0
void LostState::enter() {
  Input::Instance().m_pMouse->setBuffered(true);
	System::Instance().logMessage("Entering PauseState...");

	OgreBites::SdkTrayManager* trayManager = UserInterface::Instance().m_pTrayMgr;
	trayManager->destroyAllWidgets();
	trayManager->showCursor();
	trayManager->createDecorWidget(
	    OgreBites::TL_CENTER, "youlost", "SdkTrays/Lostthegame");
	trayManager->createButton(
	    OgreBites::TL_CENTER, "RestartGameBtn", "Restart Game", 250);
	trayManager->createButton(
	    OgreBites::TL_CENTER, "BackToMenuBtn", "Return to Menu", 250);
	trayManager->createLabel(OgreBites::TL_TOP, "PauseLbl", "Lost", 250);
	trayManager->showBackdrop("SdkTrays/Shade");
	m_bQuit = false;
}
Esempio n. 8
0
void RenderState::buildGUI()
{

        OgreBites::SdkTrayManager* trayMgr = OgreFramework::getSingletonPtr()->_trayMgr;


        trayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
        // trayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
        // trayMgr->createLabel(OgreBites::TL_TOP, "GameLbl", "Game mode", 250);
        trayMgr->showCursor();

        Ogre::StringVector items;
        items.push_back("cam.pX");
        items.push_back("cam.pY");
        items.push_back("cam.pZ");
        items.push_back("cam.oW");
        items.push_back("cam.oX");
        items.push_back("cam.oY");
        items.push_back("cam.oZ");
        items.push_back("Mode");

        _detailsPanel = trayMgr->createParamsPanel(OgreBites::TL_NONE, 
                                                     "DetailsPanel", 200, items);
        _detailsPanel->hide();

        Ogre::StringVector displayModes;
        displayModes.push_back("Solid mode");
        displayModes.push_back("Wireframe mode");
        displayModes.push_back("Point mode");
        trayMgr->createLongSelectMenu(OgreBites::TL_TOPRIGHT, 
                                      "DisplayModeSelMenu", 
                                      "Display Mode", 200, 3, displayModes);

        lightCheckBox = trayMgr->createCheckBox(OgreBites::TL_TOPLEFT, "light", 
                                                "Moving light", 200);

        tmkSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "tmk", 
                                              "tmk", 200,80,44,0,25,101);

        tmk2Slider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "tmk2", 
                                               "tmk2", 200,80,44,0,70,101);

        mintmSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "minTm", 
                                                "minTm", 200,80,44,0,1,101);

        shininessSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "shininess", 
                                                    "shininess",  200,80,44,0,10,101);

        stepsSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "steps", 
                                                "steps",  200,80,44,16,1024,241);

        ambientSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "ambient", 
                                                  "ambient",  200,80,44,-1,3,61);

        backIllumSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "backIllum", 
                                          "back illumination", 200,80,44,0,3,31);

        shadeCoeffSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "shadeCoeff", 
                                                     "shadeCoeff", 200,80,44,0.1,5,50);

        specCoeffSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "specCoeff", 
                                                     "specCoeff", 200,80,44,0.1,5,50);

        specMultSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "specMult", 
                                                     "specMult", 200,80,44,0.1,8,80);

        glowCoeffSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "glowCoeff", 
                                               "glowCoeff", 200,80,44,0,5,101);

        miscSlider = trayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "misc", 
                                               "misc", 200,80,44,0,10,101);

        // OgreBites::Button* reloadMaterialButton = 
        //         trayMgr->createButton(OgreBites::TL_RIGHT, 
        //                               "ReloadMaterial", 
        //                               "Reload material", 60);

        updateWidgets();
}
Esempio n. 9
0
bool RenderState::keyPressed(const OIS::KeyEvent &keyEventRef)
{
        OgreFramework* framework = OgreFramework::getSingletonPtr();
        OIS::Keyboard* keyboard =  framework->_keyboard;
        OgreBites::SdkTrayManager* trayMgr = framework->_trayMgr;
        OgreBites::SelectMenu* pMenu = 
                (OgreBites::SelectMenu*)trayMgr->getWidget("DisplayModeSelMenu");

        if(_settingsMode == true)
        {
                if(keyboard->isKeyDown(OIS::KC_S))
                {
                        if(pMenu->getSelectionIndex() + 1 < (int)pMenu->getNumItems())
                                pMenu->selectItem(pMenu->getSelectionIndex() + 1);
                }

                if(keyboard->isKeyDown(OIS::KC_W))
                {
                        if(pMenu->getSelectionIndex() - 1 >= 0)
                                pMenu->selectItem(pMenu->getSelectionIndex() - 1);
                }

                if(keyboard->isKeyDown(OIS::KC_R))
                {
                        steps = 20;
                }
        }

        if(keyboard->isKeyDown(OIS::KC_ESCAPE))
        {
                // pushAppState(findByName("PauseState"));
                exit();
                return true;
        }

        if(keyboard->isKeyDown(OIS::KC_I))
        {
                if(_detailsPanel->getTrayLocation() == OgreBites::TL_NONE)
                {
                        framework->_trayMgr->moveWidgetToTray(_detailsPanel, 
                                                              OgreBites::TL_BOTTOMRIGHT, 
                                                              0);
                        _detailsPanel->show();
                }
                else
                {
                        framework->_trayMgr->removeWidgetFromTray(_detailsPanel);
                        _detailsPanel->hide();
                }
        }

        if(keyboard->isKeyDown(OIS::KC_TAB))
        {
                _settingsMode = !_settingsMode;
                return true;
        }

        if(_settingsMode && keyboard->isKeyDown(OIS::KC_RETURN) ||
           keyboard->isKeyDown(OIS::KC_NUMPADENTER))
        {
        }

        if(!_settingsMode || (_settingsMode && !keyboard->isKeyDown(OIS::KC_O)))
                framework->keyPressed(keyEventRef);

        return true;
}
Esempio n. 10
0
void
MenuSystem::createMenu(MENUS menu)
{
	OgreBites::SdkTrayManager* currentTray = 0;
	switch(menu)
	{
	case STARTMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("StartMenu", mWindow, mInputContext, this);

			// Design the tray, Save the buttons if you want to check if they are pressed
			currentTray->createLabel(OgreBites::TL_TOP, "GameTitle", "Juicy Checkers", 500);
			pName = currentTray->createTextBox(OgreBites::TL_CENTER, "pName", "Enter Your Name",300,75);
			int randomNumbers = rand() % 1000;
			char bfr[256];
			char* iden = itoa(randomNumbers, bfr, 10);
			pName->setText(Ogre::String("Player")+iden);
			ip = currentTray->createTextBox(OgreBites::TL_CENTER, "ip", "Enter the Server IP",300,75);
			ip->setText("127.0.0.1");
			startButton = currentTray->createButton(OgreBites::TL_CENTER, "startBtn", "Start Multiplayer");
			exitButton = currentTray->createButton(OgreBites::TL_CENTER, "extBtn", "Exit Game");

			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;

	case LISTLOBBYMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("ListLobbyMenu", mWindow, mInputContext, this);

			// Design the tray, Save the buttons if you want to check if they are pressed
			// Create the label
			currentTray->createLabel(OgreBites::TL_TOP, "JoinCreateLobby", "Join/Create Lobby", 500);
			createLobbyButton = currentTray->createButton(OgreBites::TL_CENTER, "createLobby", "Create Lobby");
			// Have the option to create a new lobby

			// Below this we will have a listing of lobbys that the user can click on
			selectLobby = currentTray->createLongSelectMenu(OgreBites::TL_CENTER, "selectLobby", Ogre::DisplayString("Select a Lobby"), Ogre::Real(300.0), 12); 
			joinLobby = currentTray->createButton(OgreBites::TL_CENTER, "joinLobby", "Join Lobby");
			refreshLobbyButton = currentTray->createButton(OgreBites::TL_CENTER, "refreshLobby", "Refresh Lobbies");
			lobbyBack = currentTray->createButton(OgreBites::TL_CENTER, "lobbyBack", "Back");
			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;

	case CREATELOBBYMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("CreateLobbyMenu", mWindow, mInputContext, this);

			// Design the tray, Save the buttons if you want to check if they are pressed
			// Label
			currentTray->createLabel(OgreBites::TL_TOP, "CreateLobby", "Create Lobby", 500);
			lobbyName = currentTray->createTextBox(OgreBites::TL_CENTER, "lobbyName", "Lobby Name", 500 , 300);
			createLobby = currentTray->createButton(OgreBites::TL_CENTER, "createLobbyButton", "Create Lobby");
			createLobbyBack = currentTray->createButton(OgreBites::TL_CENTER, "createLobbyButtonBack", "Back");
			

			// Text area for the name

			// Button to create


			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;
	case LOBBYMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("LobbyMenu", mWindow, mInputContext, this);
			currentTray->createLabel(OgreBites::TL_TOP, "lobbyMenuTitle", "Lobby Menu", 500);
									
			// List the current players
			currentTray->createLabel(OgreBites::TL_CENTER, "lobbyMenuPlayers", "Players", 300);
			lobbyPlayersTextBox = currentTray->createTextBox(OgreBites::TL_CENTER, "lobbyPlayers", "Players",400,150);

			// Have a (ready) toggle button
			if(isReady)
			{
				lobbyReadyButton = currentTray->createButton(OgreBites::TL_CENTER, "readyButton", "READY");				
				//isReady = !isReady;
			}
			else
			{
				lobbyReadyButton = currentTray->createButton(OgreBites::TL_CENTER, "readyButton", "NOT READY");	
				//isReady = !isReady;
			}

			// Have a chat box 
			lobbyChatBox = currentTray->createTextBox(OgreBites::TL_CENTER, "chatBox", "Chat Window",500,250);
			lobbyChatTextField = currentTray->createTextBox(OgreBites::TL_CENTER, "chatTextField", "Enter Chat Here",500,80);


			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;

	case MATCHMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("MatchMenu", mWindow, mInputContext, this);

			// Design the tray, Save the buttons if you want to check if they are pressed
			// Here we will have some elements such as labels in certain positions to indicate 
			// the current turn,  timers upgrades etc etc.

			// Indicate whos turn it currently is with a label
			matchTurn = currentTray->createLabel(OgreBites::TL_TOPLEFT, "turnLabel", "Your Turn");

			// Indicate with a label the current powerup credit level
			matchCredits = currentTray->createLabel(OgreBites::TL_TOPLEFT, "powerupLabel", "Powerup Credits:0");
			// Have a button that opens up the upgrade menu

			matchUpgrade = currentTray->createButton(OgreBites::TL_TOPLEFT, "upgradeButton", "Open Upgrades");

			

			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;
	case UPGRADEMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("UpgradeMenu", mWindow, mInputContext, this);

			matchTurn = currentTray->createLabel(OgreBites::TL_CENTER, "nameLabel", "Powerup Menu");
			matchCredits = currentTray->createLabel(OgreBites::TL_CENTER, "credits", "Credits: 0");
			powerupOne = currentTray->createButton(OgreBites::TL_CENTER, "buyPU1", "Powerup One");
			powerupTwo = currentTray->createButton(OgreBites::TL_CENTER, "buyPU2", "Powerup Two");
			powerupThree = currentTray->createButton(OgreBites::TL_CENTER, "buyPU3", "Powerup Three");
			powerupBack = currentTray->createButton(OgreBites::TL_CENTER, "powerupBack", "Back");

			

			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;
	case RESULTMENU:
		{
			// Create the Tray Manager
			currentTray = new OgreBites::SdkTrayManager("ResultMenu", mWindow, mInputContext, this);

			// Design the tray, Save the buttons if you want to check if they are pressed
			// Label

			// Label results




			// Add the tray into the tray container.  NOTE: This function is designed to be run from 0 -> MENU.max
			mTrays.push_back(currentTray);
		}
		break;

	}
}
Esempio n. 11
0
CGUIManager::CGUIManager(Ogre::SceneManager *pSceneManager, Ogre::RenderTarget &target)
: CEntity("GUIManager", nullptr),
  m_pSceneManager(pSceneManager),
  m_nRenderQueue(Ogre::RENDER_QUEUE_OVERLAY),
  m_bPostQueue(false),
  m_bRenderPause(false),
  m_vNativeRes(target.getWidth(), target.getHeight()),
  m_MouseMoving(MD_COUNT, false),
  m_fMouseSpeedX(0),
  m_fMouseSpeedY(0),
  m_fMouseAcceleration(2),
  m_fMouseInitialSpeed(50) {
  CInputListenerManager::getSingleton().addInputListener(this);

  OgreBites::SdkTrayManager *pTrayMgr = CGame::getSingleton().showLoadingBar(1, 1);
  pTrayMgr->loadBarSetCaption("GUI ...");
  Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing CEGUI ***");

  Ogre::LogManager::getSingletonPtr()->logMessage("    creating bootstrapSystem");
  pTrayMgr->userUpdateLoadBar("Creating bootstrap system", 0.1);
  m_pCEGuiOgreRenderer = &CEGUI::OgreRenderer::bootstrapSystem(target);
  m_pCEGuiOgreRenderer->setFrameControlExecutionEnabled(false);

  Ogre::LogManager::getSingletonPtr()->logMessage("    setting up resource paths");
  pTrayMgr->userUpdateLoadBar("Setting up resource paths", 0.1);
  CEGUI::ImageManager::setImagesetDefaultResourceGroup("Imagesets");
  CEGUI::Font::setDefaultResourceGroup("Fonts");
  CEGUI::Scheme::setDefaultResourceGroup("Schemes");
  CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
  CEGUI::WindowManager::setDefaultResourceGroup("Layouts");

  Ogre::LogManager::getSingletonPtr()->logMessage("    creating scheme");
  pTrayMgr->userUpdateLoadBar("Creating scheme", 0.1);
  createResources();

  pSceneManager->addRenderQueueListener(this);

  Ogre::LogManager::getSingletonPtr()->logMessage("    creating root window");
  pTrayMgr->userUpdateLoadBar("Initializing the root window", 0.1);
  CEGUI::Window *guiRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MasterRoot");
  m_pRoot = guiRoot;
  //guiRoot->setAlpha(0);
  guiRoot->setSize(USize(UDim(1, 0), UDim(1, 0)));
  //guiRoot->setProperty("BackgroundEnabled", "false");
  CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(guiRoot);
  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("OgreTrayImages/MouseArrow");
  //CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("OgreTrayImages/MouseInvisible");
  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setPosition(CEGUI::Vector2f(0,0));
  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setConstraintArea(NULL);


  pTrayMgr->userUpdateLoadBar("Creating fonts", 0.2);
  createFreeTypeFont("dejavusans12", 12, "DejaVuSans.ttf");
  createFreeTypeFont("dejavusans8", 8, "DejaVuSans.ttf");
  createFreeTypeFont("dejavusans20", 20, "DejaVuSans.ttf");
  CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( "dejavusans12" );
  guiRoot->setFont("dejavusans12");


  pTrayMgr->userUpdateLoadBar("Creating gui components", 0.2);
  new CGUIDebugPullMenu(this, guiRoot, CGUIPullMenu::PMD_RIGHT);

  pTrayMgr->userUpdateLoadBar("done...", 0.2);

  Sizef vSize = CGUIManager::getSingleton().getNativeRes();

  Ogre::LogManager::getSingleton().logMessage("GUIManager initialized...");
  CGame::getSingleton().hideLoadingBar();
}