コード例 #1
0
bool SelectorHelper::SelectCharacter( const CEGUI::EventArgs& e ) {
  CEGUI::Window* window = static_cast<const CEGUI::MouseEventArgs*>(&e)->window;

  CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr();
  CEGUI::Window* penguinButton = wmgr->getWindow("Menu/Penguin");
  CEGUI::Window* ogreButton = wmgr->getWindow("Menu/Ogre");
  CEGUI::Window* ninjaButton = wmgr->getWindow("Menu/Ninja");

  if (window == penguinButton) player_flag = CHARACTER_PENGUIN;
  else if (window == ogreButton) player_flag = CHARACTER_OGRE;
  else if (window == ninjaButton) player_flag = CHARACTER_NINJA;

  if (type_flag == TYPE_SINGLE_PLAYER) {
    MenuActivity *activity = (MenuActivity*) OgreBallApplication::getSingleton()->activity;
    activity->SinglePlayerLevelSelectWrapper(e);

  } else if (type_flag == TYPE_MULTI_HOST) {
    HostPlayerActivity *activity = (HostPlayerActivity*) OgreBallApplication::getSingleton()->activity;
    activity->handlePlayerSelected(player_flag);

  } else if (type_flag == TYPE_MULTI_CLIENT) {
    ClientPlayerActivity *activity = (ClientPlayerActivity*) OgreBallApplication::getSingleton()->activity;
    activity->handlePlayerSelected(player_flag);
  }
}
コード例 #2
0
void Application::setupCEGUI()
{
	// CEGUI setup
	m_renderer = new CEGUI::OgreCEGUIRenderer(m_window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, m_sceneManager);
	m_system = new CEGUI::System(m_renderer);

	CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");

	m_system->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
	m_system->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");

	CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
	CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Sheet");

	float distanceBorder = 0.01;
	float sizeX = 0.2;
	float sizeY = 0.05;
	float posX = distanceBorder;
	float posY = distanceBorder;

	debugWindow = win->createWindow("TaharezLook/StaticText", "Widget1");
	debugWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(posX, 0), CEGUI::UDim(posY, 0)));
	debugWindow->setSize(CEGUI::UVector2(CEGUI::UDim(sizeX, 0), CEGUI::UDim(sizeY, 0)));
	debugWindow->setText("Debug Info!");

	sheet->addChildWindow(debugWindow);
	m_system->setGUISheet(sheet);
}
コード例 #3
0
bool
CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage )
{GUCEF_TRACE;
    
    CEGUI::Window* rootWindow = NULL;
    CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr();
    
    GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" );
    
    try
    {
        CORE::CDynamicBuffer memBuffer( layoutStorage );
        CEGUI::RawDataContainer container;

        container.setData( (CEGUI::uint8*) memBuffer.GetBufferPtr() );
        container.setSize( (size_t) memBuffer.GetDataSize() );

        rootWindow = wmgr->loadLayoutFromContainer( container );

        container.setData( (CEGUI::uint8*) NULL );
        container.setSize( (size_t) 0 );
    }
    catch ( CEGUI::Exception& e )
    {
        GUCEF_ERROR_LOG( 0, CString( "CEGUI Exception while attempting to load form layout: " ) + e.what() );
        return false;
    }
    
    // Now that we completed loading lets see what we got from CEGUI
    if ( NULL != rootWindow )
    {
        // Begin by providing a wrapper for the root window
        m_rootWindow = CreateAndHookWrapperForWindow( rootWindow );
        if ( NULL != m_rootWindow )
        {
            CString localWidgetName = m_rootWindow->GetName().SubstrToChar( '/', false );
            m_widgetMap[ localWidgetName ] = m_rootWindow;
            WrapAndHookChildWindows( rootWindow );
            
            // We will directly add the form as a child of the root for now
            // Note: This assumes that you have a GUISheet already set, otherwise this will result in a segfault!
            CEGUI::Window* globalRootWindow = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow();
            if ( NULL != globalRootWindow )
            {
                globalRootWindow->addChild( rootWindow );
                
                GUCEF_DEBUG_LOG( 0, "Successfully loaded a GUI Form layout" );
                return true;                
            }
            else
            {
                GUCEF_ERROR_LOG( 0, "Failed to add form as a child to the global \"root\" window" );    
            }
        }
        rootWindow->hide();
    }

    GUCEF_DEBUG_LOG( 0, "Failed to load a GUI Form layout" );
    return false; 
}
コード例 #4
0
ファイル: NetworkManager.cpp プロジェクト: jorge-d/zappy
//-------------------------------------------------------------------------------------
bool
NetworkManager::connect(const CEGUI::EventArgs&)
{
  CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
  CEGUI::String Iptmp;
  CEGUI::String PortTmp;
  unsigned int i = 1;
  if (winMgr->isWindowPresent("Connect/ContainerGrp/Ip"))
    {
      Iptmp = winMgr->getWindow("Connect/ContainerGrp/Ip")->getText();
      PortTmp = winMgr->getWindow("Connect/ContainerGrp/Port")->getText();
      this->ip_ = std::string(Iptmp.c_str());
      this->port_ = StringToNumber<const char *, int>(PortTmp.c_str());
      zappy::Convert *c = new zappy::Convert();
      zappy::Network::initInstance(this->ip_ , this->port_, *c);
      zappy::Network &p = zappy::Network::getInstance();
      p.setParameters(this->port_, this->ip_);
      p.connect_();
      if (p.isConnected())
	{
	  Thread<zappy::Network> t(p);
	  t.start();
	  while (p.gettingMap() && i < 5000)
	    usleep(++i);
	  this->GfxMgr_->hide("Connect");
	  this->GfxMgr_->createRealScene();
	}
    }
  return true;
}
コード例 #5
0
bool
CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage )
{GUCE_TRACE;
    
    CEGUI::Window* rootWindow = NULL;
    CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr();
    
    GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" );
    
    try
    {
        // provide hacky access to the given data
        m_dummyArchive->AddResource( layoutStorage, "currentFile" );

        // Now we can load the window layout from the given storage
        // Note that if CEGUI ever provides an interface to do this directly
        // clean up this mess !!!
        rootWindow = wmgr->loadWindowLayout( "currentFile"                  , 
                                             m_widgetNamePrefix.C_String()  ,
                                             m_resourceGroupName.C_String() );     
        m_dummyArchive->ClearResourceList();
    }
    catch ( Ogre::Exception& e )
    {
        GUCEF_ERROR_LOG( 0, CString( "Ogre Exception while attempting to load form layout: " ) + e.getFullDescription().c_str() );
        return false;
    }
    
    // Now that we completed loading lets see what we got from CEGUI
    if ( NULL != rootWindow )
    {
        // Begin by providing a wrapper for the root window
        m_rootWindow = CreateAndHookWrapperForWindow( rootWindow );
        if ( NULL != m_rootWindow )
        {
            CString localWidgetName = m_rootWindow->GetName().SubstrToChar( '/', false );
            m_widgetMap[ localWidgetName ] = m_rootWindow;
            WrapAndHookChildWindows( rootWindow );
            
            // We will directly add the form as a child of the root for now
            CEGUI::Window* globalRootWindow = wmgr->getWindow( "root" );
            if ( NULL != globalRootWindow )
            {
                globalRootWindow->addChildWindow( rootWindow );
                
                GUCEF_DEBUG_LOG( 0, "Successfully loaded a GUI Form layout" );
                return true;                
            }
            else
            {
                GUCEF_ERROR_LOG( 0, "Failed to add form as a child to the global \"root\" window" );    
            }
        }
        rootWindow->hide();
    }

    GUCEF_DEBUG_LOG( 0, "Failed to loaded a GUI Form layout" );
    return false; 
}
コード例 #6
0
ファイル: main.cpp プロジェクト: jdahlbom/ApMech
/**
 * Create all widgets and their initial contents.
 *
 * CEGUI is based on tree structure of Windows. On top of that
 * tree is a GUISheet, named "root". Each child has a position and
 * a size - both given as values relative to the parent elements area.
 * Position is given as the top left corner of a child within the parent area.
 * Size is given as the relative portions of the parent area.
 */
void createGUIWindow()
{
    CEGUI::System *ceguiSystem= CEGUI::System::getSingletonPtr();
    assert(ceguiSystem);
    CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
    assert(winMgr);

    CEGUI::Window *ceguiRoot = winMgr->createWindow("DefaultGUISheet","root");
    assert(ceguiRoot);
    ceguiSystem->setGUISheet(ceguiRoot); // Top element, fills the display area

    CEGUI::UVector2 buttonSize = CEGUI::UVector2(CEGUI::UDim(0.6, 0), CEGUI::UDim(0.1, 0));

    setupCEGUIResources();

    // Create a button of type "TaharezLook/Button" and name "root/Button"
    mButton = winMgr->createWindow(
        reinterpret_cast<const CEGUI::utf8*>("TaharezLook/Button"),
        reinterpret_cast<const CEGUI::utf8*>("root/Button"));

    mButton->setAlpha(0.5f);
    mButton->setText("Hello World!");
    mButton->setSize(buttonSize);
    mButton->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2, 0), CEGUI::UDim(0.6, 0)));

    mEditBox = winMgr->createWindow(
	reinterpret_cast<const CEGUI::utf8*>("TaharezLook/Editbox"),
	reinterpret_cast<const CEGUI::utf8*>("root/EditBox"));
    mEditBox->setAlpha(0.5f);
    mEditBox->setSize(CEGUI::UVector2(CEGUI::UDim(0.6, 0), CEGUI::UDim(0.1, 0)));
    mEditBox->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2, 0), CEGUI::UDim(0.3, 0)));

    // Add both created elements to the GUI sheet.
    ceguiRoot->addChildWindow(mEditBox);
    ceguiRoot->addChildWindow(mButton);

    /* Add event subscribers to both elements.
     * CEGUI input handling is based on function pointers being subscribed
     * to certain events - events of each window type are defined in the 
     * CEGUI API docs.  When the event occurs, all subscriber functions
     * are called (in some order?)
     */
    // EventTextAccepted occurs when input box has focus, and user presses
    // Enter, Return or Tab, and so accepts the input.
    mEditBox->subscribeEvent(CEGUI::Editbox::EventTextAccepted,
			     CEGUI::Event::Subscriber(&inputEntered));
    // EventClicked occurs when button is clicked.
    mButton->subscribeEvent(CEGUI::PushButton::EventClicked,
			    CEGUI::Event::Subscriber(&inputEntered));
}
コード例 #7
0
LoginScreenInterface::LoginScreenInterface(){
#ifdef WITH_CEGUI_SUPPORT
    CEGUI::WindowManager *wmanager = CEGUI::WindowManager::getSingletonPtr();

    m_LoginScreenWindow = wmanager->loadWindowLayout(
        "loginscreen.layout",
        ""
    );

    if (m_LoginScreenWindow)
    {
        CEGUI::System::getSingleton().getGUISheet()->addChildWindow(m_LoginScreenWindow);
    }
#endif
}
コード例 #8
0
void MyGUI::update(float timeSinceLastFrame) 
{
	//在這裡更新衛星的狀態
	CEGUI::WindowManager* winMgr = 	CEGUI::WindowManager::getSingletonPtr(); 
	//衛星的狀態
	CEGUI::String str_status;
	if(SatelliteStatus::current_status == SatelliteStatus::UNLAUNCHED){
		str_status = GetUTF(L"未发射");
	}
	else if(SatelliteStatus::current_status == SatelliteStatus::RISING){
		str_status = GetUTF(L"上升中");
	}
	else if(SatelliteStatus::current_status == SatelliteStatus::NEAR_TRACK){
		str_status = GetUTF(L"近地轨道");
	}
	else if(SatelliteStatus::current_status == SatelliteStatus::ECLLIPSE){
		str_status = GetUTF(L"椭圆轨道");
	}
	else if(SatelliteStatus::current_status == SatelliteStatus::FAR_TRACK){
		str_status = GetUTF(L"远地轨道");
	}
	else if(SatelliteStatus::current_status == SatelliteStatus::OUT_CONTROL){
		str_status = GetUTF(L"失控");
	}
	winMgr->getWindow("text_status")->setText(str_status);

	//卫星的坐标
	char buffer0[1024];
	char buffer1[1024];
	char buffer2[1024];
	sprintf(buffer0,"%f",SatelliteStatus::satellite_x);
	sprintf(buffer1,"%f",SatelliteStatus::satellite_y);
	sprintf(buffer2,"%f",SatelliteStatus::satellite_z);
	CEGUI::String strx(buffer0);
	CEGUI::String stry(buffer1);
	CEGUI::String strz(buffer2);
	winMgr->getWindow("text_x")->setText(strx);
	winMgr->getWindow("text_y")->setText(stry);
	winMgr->getWindow("text_z")->setText(strz);
	//卫星自转角
	sprintf(buffer0,"%f",SatelliteStatus::satellite_angle);
	CEGUI::String str_rotate(buffer0);
	winMgr->getWindow("text_axisaxis")->setText(strx);
	//线速度
	sprintf(buffer0,"%f km/h",SatelliteStatus::satellite_lv);
	CEGUI::String str_lv(buffer0);
	winMgr->getWindow("text_lvlv")->setText(str_lv);
	//角速度
	sprintf(buffer0,"%f /h",SatelliteStatus::satellite_wv);
	CEGUI::String str_wv(buffer0);
	winMgr->getWindow("text_wvwv")->setText(str_wv);
	//线加速度
	sprintf(buffer0,"%f /h^2",SatelliteStatus::satellite_a);
	CEGUI::String str_a(buffer0);
	winMgr->getWindow("text_aa")->setText(str_a);

	MyGUISystem::getSingletonPtr()->update(timeSinceLastFrame);
}
コード例 #9
0
ファイル: NetworkManager.cpp プロジェクト: jorge-d/zappy
//-------------------------------------------------------------------------------------
bool
NetworkManager::updateTime(const CEGUI::EventArgs&)
{
  CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
  std::string time;
  std::string s;

  if (winMgr->isWindowPresent("Time/Container/Time"))
    {
      zappy::Network &net = zappy::Network::getInstance();

      time = winMgr->getWindow("Time/Container/Time")->getText().c_str();
      s = "sst " + time + "\n";
      net.setToSend(s);
    }
  return true;
}
コード例 #10
0
void SelectorHelper::SwitchToPlayerSelectMenu(void) {
  CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr();

  CEGUI::System::getSingleton().setGUISheet(wmgr->getWindow("Menu/PlayerSelect"));
  CEGUI::Window* penguinButton = wmgr->getWindow("Menu/Penguin");
  CEGUI::Window* ogreButton = wmgr->getWindow("Menu/Ogre");
  CEGUI::Window* ninjaButton = wmgr->getWindow("Menu/Ninja");

  penguinButton->subscribeEvent(CEGUI::PushButton::EventClicked,
                                &SelectorHelper::SelectCharacter);

  ogreButton->subscribeEvent(CEGUI::PushButton::EventClicked,
                             &SelectorHelper::SelectCharacter);

  ninjaButton->subscribeEvent(CEGUI::PushButton::EventClicked,
                              &SelectorHelper::SelectCharacter);
}
コード例 #11
0
void GameConsoleWindow::CreateCEGUIWindow()
{
	// Get a local pointer to the CEGUI Window Manager, Purely for convenience to reduce typing
	CEGUI::WindowManager *pWindowManager = CEGUI::WindowManager::getSingletonPtr();
 
    // Now before we load anything, lets increase our instance number to ensure no conflicts.  
    // I like the format #_ConsoleRoot so thats how i'm gonna make the prefix.  This simply
    // Increments the iInstanceNumber then puts it + a _ into the sNamePrefix string. 
    sNamePrefix = ++iInstanceNumber + "_";
 
    // Now that we can ensure that we have a safe prefix, and won't have any naming conflicts lets create the window
    // and assign it to our member window pointer m_ConsoleWindow
    // inLayoutName is the name of your layout file (for example "console.layout"), don't forget to rename inLayoutName by our layout file
	CasaEngine::IFile* pFile = CasaEngine::MediaManager::Instance().FindMedia("GameConsole.layout", CasaEngine::FileMode::READ);
	if (pFile != nullptr)
	{
		CEGUI::String xmlStr(pFile->GetBuffer());
		m_ConsoleWindow = pWindowManager->loadLayoutFromString(xmlStr);
		DELETE_AO pFile;
		pFile = nullptr;
	}
	else
	{
		throw CasaEngine::CLoadingFailed("GameConsole.layout", "");
	}
 
    // Being a good programmer, its a good idea to ensure that we got a valid window back. 
    if (m_ConsoleWindow)
    {
		CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(m_ConsoleWindow);

        // Lets add our new window to the Root GUI Window
        //CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChildWindow(m_ConsoleWindow);
		//CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(m_ConsoleWindow);
        // Now register the handlers for the events (Clicking, typing, etc)
        (this)->RegisterHandlers();
    }
    else
    {
        // Something bad happened and we didn't successfully create the window lets output the information
        CEGUI::Logger::getSingleton().logEvent("Error: Unable to load the ConsoleWindow from .layout");
    }
}
コード例 #12
0
void InGameMenuWindow::createMenu(MenuBase* menu)
{
	CEGUI::WindowManager* windowMan = CEGUI::WindowManager::getSingletonPtr();

	const ActionVector actions = ActionManager::getSingleton().getInGameGlobalActions();
	map<CeGuiString, PopupMenu*> menuGroups;

	for (ActionVector::const_iterator actIter = actions.begin(); actIter != actions.end(); actIter++)
	{
        Action* action = *actIter;
		ActionGroup* group = action->getGroup();
		if (group != NULL)
		{
			PopupMenu* menuGrp;
			map<CeGuiString, PopupMenu*>::iterator grpIter = menuGroups.find(group->getName());
			if (grpIter != menuGroups.end())
			{
				menuGrp = (*grpIter).second;
			}
			else
			{
				MenuItem* grpItem = static_cast<MenuItem*>(windowMan->createWindow("RastullahLook/MenuItem",
					getNamePrefix()+"IngameMenu/"+group->getName()));
				grpItem->setText(group->getName());
				menu->addChildWindow(grpItem);

				menuGrp = static_cast<PopupMenu*>(windowMan->createWindow("RastullahLook/PopupMenu",
					getNamePrefix()+"IngameMenu/Menu"+group->getName()));
				grpItem->addChildWindow(menuGrp);

				menuGroups[group->getName()] = menuGrp;
			}

			MenuItem* item = static_cast<MenuItem*>(windowMan->createWindow("RastullahLook/MenuItem",
				getNamePrefix()+"IngameMenu/"+group->getName()+"/"+action->getName()));
			item->setText(action->getDescription());
			menuGrp->addChildWindow(item);

			setAction(item, action);
		}
	}
}
コード例 #13
0
//近地点加速
bool EventSpeedUp(const CEGUI::EventArgs& e)
{
	/*if(SatelliteStatus::current_status != SatelliteStatus::NEAR_TRACK){
		//TODO: Anouce BUG
		return true;
	}
	SatelliteStatus::current_status = SatelliteStatus::ECLLIPSE;*/
	if(SatelliteStatus::current_status != SatelliteStatus::UNLAUNCHED){
		return false;
	}
	//Read the Data and set it
	double near_ = 468.55;
	double far_ = 800.00;
	CEGUI::WindowManager* winMgr = 	CEGUI::WindowManager::getSingletonPtr(); 
	CEGUI::String& strnear = const_cast<CEGUI::String&>(winMgr->getWindow("edit_near")->getText() );
	CEGUI::String& strfar  = const_cast<CEGUI::String&>(winMgr->getWindow("edit_far")->getText() );
	near_ = atof(strnear.c_str() );
	far_ = atof(strfar.c_str() );
	SetParameter(near_,far_);
	return true;
}
コード例 #14
0
ファイル: testaarhud.cpp プロジェクト: VRAC-WATCH/deltajug
CEGUI::Window* TestAARHUD::CreateText(const std::string& name, CEGUI::Window* parent, const std::string& text,
                                 float x, float y, float width, float height)
{
   CEGUI::WindowManager* wm = CEGUI::WindowManager::getSingletonPtr();

   // create base window and set our default attribs
   CEGUI::Window* result = wm->createWindow("WindowsLook/StaticText", name);
   parent->addChildWindow(result);
   result->setText(text);
   result->setPosition(CEGUI::UVector2(cegui_absdim(x), cegui_absdim(y)));
   result->setSize(CEGUI::UVector2(cegui_absdim(width), cegui_absdim(height)));
   result->setProperty("FrameEnabled", "false");
   result->setProperty("BackgroundEnabled", "false");
   result->setHorizontalAlignment(CEGUI::HA_LEFT);
   result->setVerticalAlignment(CEGUI::VA_TOP);
   // set default color to white
   result->setProperty("TextColours", 
      CEGUI::PropertyHelper::colourToString(CEGUI::colour(1.0f, 1.0f, 1.0f)));
   result->show();

   return result;
}
コード例 #15
0
void BasicWindow::createGUI(void) {
	mRenderer = &CEGUI::OgreRenderer::bootstrapSystem();
	
	CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
	CEGUI::Font::setDefaultResourceGroup("Fonts");
	CEGUI::Scheme::setDefaultResourceGroup("Schemes");
	CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
	CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
	
	CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
	CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");

	CEGUI::WindowManager* winMgr = CEGUI::WindowManager::getSingletonPtr();
	CEGUI::System* guiSystem     = CEGUI::System::getSingletonPtr();
	CEGUI::Window* rootWindow    = winMgr->createWindow("DefaultWindow", "root");
	guiSystem->setGUISheet(rootWindow);

	/* not using the gui quite yet:
	try {
		rootWindow->addChildWindow(CEGUI::WindowManager::getSingleton().loadWindowLayout("Console.layout"));
		rootWindow->addChildWindow(CEGUI::WindowManager::getSingleton().loadWindowLayout("RightPanel.layout"));
	} catch (CEGUI::Exception& e) {
		OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, std::string(e.getMessage().c_str()), "Error parsing gui layout");
	}
	*/

	/*
	// "Quit" button:
	CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
	CEGUI::Window* sheet         = winMgr.createWindow("DefaultWindow", "CEGUIDemo/Sheet");
	CEGUI::Window* quit          = winMgr.createWindow("TaharezLook/Button", "CEGUIDemo/QuitButton");
	quit->setText("Quit");
	quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.15f, 0), CEGUI::UDim(0.05f, 0)));
	quit->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BasicWindow::quit, this));
	sheet->addChildWindow(quit);
	CEGUI::System::getSingleton().setGUISheet(sheet);
	*/
}
コード例 #16
0
ファイル: testaarhud.cpp プロジェクト: VRAC-WATCH/deltajug
void TestAARHUD::SetupGUI(dtCore::DeltaWin& win,
                          dtCore::Keyboard& keyboard,
                          dtCore::Mouse& mouse)
{
   char clin[HUDCONTROLMAXTEXTSIZE]; // general buffer to print
   float curYPos;
   float helpTextWidth = 400;
   float taskTextWidth = 300;

   try
   {
      // Initialize CEGUI
      mGUI = new dtGUI::CEUIDrawable(&win, &keyboard, &mouse);

      std::string scheme = "gui/schemes/WindowsLook.scheme";
      std::string path = dtCore::FindFileInPathList(scheme);
      if (path.empty())
      {
         throw dtUtil::Exception(ARRHUDException::INIT_ERROR,
            "Failed to find the scheme file.", __FILE__, __LINE__);
      }

      std::string dir = path.substr(0, path.length() - (scheme.length() - 3));
      dtUtil::FileUtils::GetInstance().PushDirectory(dir);
      CEGUI::SchemeManager::getSingleton().loadScheme(path);
      dtUtil::FileUtils::GetInstance().PopDirectory();

      CEGUI::WindowManager* wm = CEGUI::WindowManager::getSingletonPtr();
      CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");
      CEGUI::System::getSingleton().getDefaultFont()->setProperty("PointSize", "14");

      mMainWindow = wm->createWindow("DefaultGUISheet", "root");
      CEGUI::System::getSingleton().setGUISheet(mMainWindow);

      // MEDIUM FIELDS - on in Medium or max

      mHUDOverlay = wm->createWindow("WindowsLook/StaticImage", "medium_overlay");
      mMainWindow->addChildWindow(mHUDOverlay);
      mHUDOverlay->setPosition(CEGUI::UVector2(cegui_reldim(0.0f),cegui_reldim(0.0f)));
      mHUDOverlay->setSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim(1.0f)));
      mHUDOverlay->setProperty("FrameEnabled", "false");
      mHUDOverlay->setProperty("BackgroundEnabled", "false");

      // Main State - idle/playback/record
      mStateText = CreateText("State Text", mHUDOverlay, "", 10.0f, 20.0f, 120.0f, mTextHeight + 5);
      mStateText->setProperty("TextColours", "tl:FFFF1919 tr:FFFF1919 bl:FFFF1919 br:FFFF1919");
      //mStateText->setFont("DejaVuSans-10");

      // Core sim info
      mSimTimeText = CreateText("Sim Time", mHUDOverlay, "Sim Time",
         0.0f, 0.0f, mRightTextXOffset - 2, mTextHeight);
      mSpeedFactorText = CreateText("Speed Factor", mHUDOverlay, "Speed",
         0.0f, 0.0f, mRightTextXOffset - 2, mTextHeight);

      // Detailed record/playback info
      mRecordDurationText = CreateText(std::string("Duration"), mHUDOverlay, std::string("Duration"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mNumMessagesText = CreateText(std::string("Num Msgs"), mHUDOverlay, std::string("Num Msgs"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mNumTagsText = CreateText(std::string("Num Tags"), mHUDOverlay, std::string("Num Tags"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mLastTagText = CreateText(std::string("Last Tag"), mHUDOverlay, std::string("LastTag:"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mNumFramesText = CreateText(std::string("Num Frames"), mHUDOverlay, std::string("Num Frames"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mLastFrameText = CreateText(std::string("Last Frame"), mHUDOverlay, std::string("Last Frame"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mCurLogText = CreateText(std::string("Cur Log"), mHUDOverlay, std::string("Cur Log"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mCurMapText = CreateText(std::string("Cur Map"), mHUDOverlay, std::string("Cur Map"),
         0, 0, mRightTextXOffset - 2, mTextHeight);

      // Core Tips at top of screen (HUD Toggle and Help)
      mFirstTipText = CreateText(std::string("First Tip"), mHUDOverlay, std::string("(F2 for MED HUD)"),
         0, mTextYTopOffset, 160, mTextHeight + 2);
      mFirstTipText->setHorizontalAlignment(CEGUI::HA_CENTRE);
      mSecondTipText = CreateText(std::string("Second Tip"), mHUDOverlay, std::string("  (F1 for Help)"),
         0, mTextYTopOffset + mTextHeight + 3, 160, mTextHeight + 2);
      mSecondTipText->setHorizontalAlignment(CEGUI::HA_CENTRE);


      // TASK FIELDS

      // task header
      curYPos = 70;
      mTasksHeaderText = CreateText(std::string("Task Header"), mHUDOverlay, std::string("Tasks:"),
         4, curYPos, taskTextWidth - 2, mTextHeight + 2);
      //mTasksHeaderText->setFont("DejaVuSans-10");
      curYPos += 2;

      // 11 placeholders for tasks
      for (int i = 0; i < 11; i++)
      {
         snprintf(clin, HUDCONTROLMAXTEXTSIZE, "Task %i", i);
         curYPos += mTextHeight + 2;
         mTaskTextList.push_back(CreateText(std::string(clin), mHUDOverlay, std::string(clin),
            12, curYPos, taskTextWidth - 2, mTextHeight + 2));
      }

      // HELP FIELDS

      mHelpOverlay = static_cast<CEGUI::Window*>(wm->createWindow
         ("WindowsLook/StaticImage", "Help Overlay"));
      mMainWindow->addChildWindow(mHelpOverlay);
      mHelpOverlay->setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f)));
      mHelpOverlay->setSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim(1.0f)));
      mHelpOverlay->setProperty("FrameEnabled", "false");
      mHelpOverlay->setProperty("BackgroundEnabled", "false");
      mHelpOverlay->hide();

      // help tip
      mHelpTipText = CreateText(std::string("Help Tip"), mHelpOverlay, std::string("(F2 to Toggle HUD)"),
         0, mTextYTopOffset, 160, mTextHeight + 2);
      mHelpTipText->setHorizontalAlignment(CEGUI::HA_CENTRE);

      // HELP - Speed Settings
      curYPos = mTextYTopOffset;
      mHelp1Text = CreateText(std::string("Help1"), mHelpOverlay, std::string("[-] Slower (min 0.1X)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp2Text = CreateText(std::string("Help2"), mHelpOverlay, std::string("[+] Faster (max 10.0X)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp3Text = CreateText(std::string("Help3"), mHelpOverlay, std::string("[0] Normal Speed (1.0X)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp7Text = CreateText(std::string("Help7"), mHelpOverlay, std::string("[P] Pause/Unpause"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Camera Movement
      curYPos += mTextHeight * 2;
      mHelp17Text = CreateText(std::string("Help17"), mHelpOverlay, std::string("[Mouse] Turn Camera"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp13Text = CreateText(std::string("Help13"), mHelpOverlay, std::string("[A & D] Move Camera Left & Right"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp14Text = CreateText(std::string("Help14"), mHelpOverlay, std::string("[W & S] Move Camera Forward and Back"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Player Movement
      curYPos += mTextHeight * 2;
      mHelp15Text = CreateText(std::string("Help15"), mHelpOverlay, std::string("[J & L] Turn Player Left & Right"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp16Text = CreateText(std::string("Help16"), mHelpOverlay, std::string("[I & K] Move Player Forward and Back"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Idle, Record, and playback
      curYPos += mTextHeight * 2;
      mHelp4Text = CreateText(std::string("Help4"), mHelpOverlay, std::string("[1] Goto IDLE Mode (Ends record & playback)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp5Text = CreateText(std::string("Help5"), mHelpOverlay, std::string("[2] Begin RECORD Mode (From Idle ONLY)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp6Text = CreateText(std::string("Help6"), mHelpOverlay, std::string("[3] Begin PLAYBACK Mode (From Idle ONLY)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp18Text = CreateText(std::string("Help18"), mHelpOverlay, std::string("[< & >] Prev & Next Keyframe (From Playback ONLY)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Misc
      curYPos += mTextHeight * 2;
      mHelp8Text = CreateText(std::string("Help8"), mHelpOverlay, std::string("[B] Place Object"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight * 2;
      mHelp19Text = CreateText(std::string("Help19"), mHelpOverlay, std::string("[G] Place Ignorable Object"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp11Text = CreateText(std::string("Help11"), mHelpOverlay, std::string("[F] Insert Keyframe"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp12Text = CreateText(std::string("Help12"), mHelpOverlay, std::string("[T] Insert Tag"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp9Text = CreateText(std::string("Help9"), mHelpOverlay, std::string("[Enter] Toggle Statistics"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp10Text = CreateText(std::string("Help10"), mHelpOverlay, std::string("[Space] Update Logger Status"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // finally, update our state - disable/hide to make it match current state
      UpdateState();

      // Note - don't forget to add the cegui drawable to the scene after this method, or you get nothing.
   }
   catch (CEGUI::Exception& e)
   {
      std::ostringstream oss;
      oss << "CEGUI while setting up AAR GUI: " << e.getMessage().c_str();
      throw dtUtil::Exception(ARRHUDException::INIT_ERROR,oss.str(), __FILE__, __LINE__);
   }

}
コード例 #17
0
ファイル: OgreWiiApp.cpp プロジェクト: mcleanjusten/wiimpp
void OgreWiiApp::setupCEGUI()
{
    //mWindow = mRoot->getAutoCreatedWindow();
    mRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
    mSystem = new CEGUI::System(mRenderer);

	CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");
	mSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
    mSystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");

	CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
	CEGUI::Window *sheet = winMgr->createWindow("DefaultGUISheet", "Vp/Sheet");

  CEGUI::UVector2 buttonSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0));
  CEGUI::UVector2 checkboxSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0));
  CEGUI::UVector2 comboboxSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.15, 0));
  CEGUI::UVector2 infoboxSize(CEGUI::UDim(0.5, 0.0), CEGUI::UDim(0.1, 0.0));
  CEGUI::UVector2 controlboxSize(CEGUI::UDim(0.5, 0.0), CEGUI::UDim(0.5, 0.0));
  CEGUI::UVector2 scrollSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.025, 0));
  float dy = 0.06f;
  float y = 0.01f;

	CEGUI::Window *win = winMgr->createWindow("TaharezLook/Editbox", "Vp/OscAddress");
	win->setText(mAddress);
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(buttonSize);
	sheet->addChildWindow(win);

  y+=dy;
	win = winMgr->createWindow("TaharezLook/Editbox", "Vp/OscPort");
  win->setText(StringConverter::toString(mPort));
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(buttonSize);
	sheet->addChildWindow(win);

  y+=dy;
	win = winMgr->createWindow("TaharezLook/Button", "Vp/Reconnect");
	win->setText("Reconnect");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(buttonSize);
	sheet->addChildWindow(win);

  y+=dy;
	win = winMgr->createWindow("TaharezLook/Checkbox", "Vp/FirstPersonView");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
  win->setText("First Person View");
	win->setSize(checkboxSize);
	sheet->addChildWindow(win);

  y+=dy;
	win = winMgr->createWindow("TaharezLook/HorizontalScrollbar", "Vp/Scrollbar1");
	win->setText("Scrollbar1");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(scrollSize);
	sheet->addChildWindow(win);

  y+=dy;
	win = winMgr->createWindow("TaharezLook/HorizontalScrollbar", "Vp/Scrollbar2");
	win->setText("Scrollbar1");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(scrollSize);
	sheet->addChildWindow(win);

  y+=dy;
	win = winMgr->createWindow("TaharezLook/HorizontalScrollbar", "Vp/Scrollbar3");
	win->setText("Scrollbar1");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(scrollSize);
	sheet->addChildWindow(win);

  // Snapshot button
  y+=dy;
	win = winMgr->createWindow("TaharezLook/Button", "Vp/SnapButton");
	win->setText("Shapshot");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(buttonSize);
	sheet->addChildWindow(win);

  // Quit button
  y+=dy;
	win = winMgr->createWindow("TaharezLook/Button", "Vp/QuitButton");
	win->setText("Quit");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) );
	win->setSize(buttonSize);
	sheet->addChildWindow(win);

  // Info txt box
  win = winMgr->createWindow("TaharezLook/StaticText", "Vp/TextBoxInfo");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( 0.85f, 0 ) ) );
  win->setSize(infoboxSize);
  sheet->addChildWindow(win);

  // Info txt box
  win = winMgr->createWindow("TaharezLook/StaticText", "Vp/TextBoxAR");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.6f, 0 ), CEGUI::UDim( 0.85f, 0 ) ) );
  win->setSize(infoboxSize);
  win->setVisible(true);
  sheet->addChildWindow(win);

  // Controls txt box
  /*
	win = winMgr->createWindow("TaharezLook/StaticText", "Vp/TextBoxControls");
  win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.5f, 0 ), CEGUI::UDim( 0.0f, 0 ) ) );
  win->setSize(controlboxSize);
  sheet->addChildWindow(win);
  */

  mSystem->setGUISheet(sheet);


}
コード例 #18
0
void CMainMenuWindowHandler::init()
{
    CEGUI::WindowManager *windowMngr = CEGUI::WindowManager::getSingletonPtr();

    m_OnLineCommunityButton     = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/OnLineCommunityButton"));
    m_virtualChampionshipButton = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/VirtualChampionshipButton"));
    m_newManagerGameButton	    = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/NewManagerGameButton"));
    m_ProfessionalCareerButton  = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/ProfessionalCareerButton"));
    m_EditorButton              = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/EditorButton"));
    m_FootLibraryButton         = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/FootLibraryButton"));
    m_configButton			    = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/ConfigButton"));
    m_creditsButton			    = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/CreditsButton"));
    m_quickLoadButton		    = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/QuickLoadButton"));
    m_loadGameButton	        = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/LoadGameButton"));
    m_quitButton		  	    = static_cast<CEGUI::PushButton*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/QuitButton"));
    m_currentDate       	    = static_cast<CEGUI::Window*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/CurrentDate"));
    m_versionDate       	    = static_cast<CEGUI::Window*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/VersionDate"));
    m_version           	    = static_cast<CEGUI::Window*>(windowMngr->getWindow((CEGUI::utf8*)"MainMenu/Version"));

    // Event handle
    registerEventConnection(m_virtualChampionshipButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::virtualChampionshipButtonClicked, this)));
    registerEventConnection(m_EditorButton             ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::editorButtonClicked, this)));
    registerEventConnection(m_newManagerGameButton     ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::newManagerGameButtonClicked, this)));
    registerEventConnection(m_configButton             ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::configButtonClicked, this)));
    registerEventConnection(m_creditsButton            ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::creditsButtonClicked, this)));
    registerEventConnection(m_loadGameButton           ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::loadGameButtonClicked, this)));
    registerEventConnection(m_quickLoadButton          ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::quickLoadButtonClicked, this)));
    registerEventConnection(m_quitButton               ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CMainMenuWindowHandler::quitButtonClicked, this)));

    // i18n support
    m_OnLineCommunityButton    ->setText((CEGUI::utf8*)gettext("On-line Community"));
    m_virtualChampionshipButton->setText((CEGUI::utf8*)gettext("Virtual Championship"));
    m_newManagerGameButton     ->setText((CEGUI::utf8*)gettext("Manager League"));
    m_ProfessionalCareerButton ->setText((CEGUI::utf8*)gettext("Professional Career"));
    m_EditorButton             ->setText((CEGUI::utf8*)gettext("Editor"));
    m_FootLibraryButton        ->setText((CEGUI::utf8*)gettext("Football Library"));
    m_configButton             ->setText((CEGUI::utf8*)gettext("Configuration"));
    m_creditsButton            ->setText((CEGUI::utf8*)gettext("Credits"));
    m_quickLoadButton          ->setTooltipText((CEGUI::utf8*)gettext("Quick Load"));
    m_loadGameButton           ->setTooltipText((CEGUI::utf8*)gettext("Load"));
    m_quitButton               ->setTooltipText((CEGUI::utf8*)gettext("Quit"));
    windowMngr->getWindow((CEGUI::utf8*)"MainMenu/CurrentDateLabel")->setText((CEGUI::utf8*)gettext("Today is:"));
    windowMngr->getWindow((CEGUI::utf8*)"MainMenu/VersionDateLabel")->setText((CEGUI::utf8*)gettext("Last update:"));
}
コード例 #19
0
bool MyGUI::init()
{
	bool ret_value = MyGUISystem::getSingletonPtr()->init();
	//加载窗口
	if(ret_value){
		MyGUISystem::getSingletonPtr()->loadLayout("GameGUI");
		//设置按钮等文本为中文
		// 得到窗口管理单件
		CEGUI::WindowManager* winMgr = 	CEGUI::WindowManager::getSingletonPtr(); 
		//bool is_presented = winMgr->isWindowPresent("WindowControl");
		//CEGUI::Window* win = winMgr->getWindow("GameGUI");
	
		//int mmm = 0;
		//winMgr->getWindow("WindowControl")->setText(GetUTF(L"控制选项:") );
		
		winMgr->getWindow("WindowControl_text_near")->setText(GetUTF(L"近地轨道半径(10km):") );
		winMgr->getWindow("WindowControl_text_far")->setText(GetUTF(L"远地轨道半径(10km):") );
		winMgr->getWindow("button_launch")->setText(GetUTF(L"发射卫星") );
		winMgr->getWindow("button_speed_up")->setText(GetUTF(L"更新参数"));
		winMgr->getWindow("edit_near")->setText(GetUTF(L"468.55") );
		winMgr->getWindow("edit_far")->setText(GetUTF(L"800.00"));

		//winMgr->getWindow("WindowRender")->setText(GetUTF(L"渲染选项:") );
		winMgr->getWindow("select_viewport")->setText(GetUTF(L"视角:") );
		winMgr->getWindow("select_show_track")->setText(GetUTF(L"显示卫星轨迹") );
		
		//winMgr->getWindow("WindowShow")->setText(GetUTF(L"参数显示:") );
		winMgr->getWindow("text_param")->setText(GetUTF(L"卫星参数:") );
		winMgr->getWindow("text_st")->setText(GetUTF(L"卫星状态") );
		winMgr->getWindow("text_status")->setText(GetUTF(L"未发射") );
		winMgr->getWindow("text_coords")->setText(GetUTF(L"卫星坐标(10km):") );
		winMgr->getWindow("text_coords_x")->setText(GetUTF(L"X坐标:") );
		winMgr->getWindow("text_coords_y")->setText(GetUTF(L"Y坐标:") );
		winMgr->getWindow("text_coords_z")->setText(GetUTF(L"Z坐标:") );
		winMgr->getWindow("text_x")->setText(GetUTF(L"0") );
		winMgr->getWindow("text_y")->setText(GetUTF(L"0") );
		winMgr->getWindow("text_z")->setText(GetUTF(L"0") );
		winMgr->getWindow("text_axis")->setText(GetUTF(L"卫星自转角:") );
		winMgr->getWindow("text_axisaxis")->setText(GetUTF(L"0") );
		winMgr->getWindow("text_lv")->setText(GetUTF(L"卫星线速度:") );
		winMgr->getWindow("textwv")->setText(GetUTF(L"卫星角速度:") );
		winMgr->getWindow("text_a")->setText(GetUTF(L"卫星加速度:") );
		winMgr->getWindow("text_lvlv")->setText(GetUTF(L"0 km/h") );
		winMgr->getWindow("text_wvwv")->setText(GetUTF(L"0 /h") );
		winMgr->getWindow("text_aa")->setText(GetUTF(L"0 km/h2") );

		//设置“选择视角”的ListBox
		CEGUI::ListboxTextItem* item1 = new CEGUI::ListboxTextItem((GetUTF(L"大气层内")),0 );
		CEGUI::ListboxTextItem* item2 = new CEGUI::ListboxTextItem((GetUTF(L"外太空")),1 );
		CEGUI::ListboxTextItem* item3 = new CEGUI::ListboxTextItem((GetUTF(L"南极上方")),2 );
		CEGUI::ListboxTextItem* item4 = new CEGUI::ListboxTextItem((GetUTF(L"自由视角")),3 );
		CEGUI::Combobox* list_box_select_viewport = (CEGUI::Combobox*)(winMgr->getWindow("select_viewport") );
		list_box_select_viewport->addItem(item1);
		list_box_select_viewport->addItem(item2);
		list_box_select_viewport->addItem(item3);
		list_box_select_viewport->addItem(item4);

		//设置“显示轨迹”的Checkbox
		CEGUI::Checkbox* check_box = (CEGUI::Checkbox*)(winMgr->getWindow("select_show_track") );
		check_box->setSelected(false);
		
		//设置
		//这次注册一些事件处理函数等
		//“选择视角”的ListBox
		//item3->subscribeEvent(CEGUI::Window::EventMouseButtonDown,CEGUI::Event::Subscriber(EventSelectNP));
		list_box_select_viewport->subscribeEvent(CEGUI::Combobox::EventTextSelectionChanged,CEGUI::Event::Subscriber(EventSelectView));

		//设置“显示轨迹的”CheckBox
		check_box->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged,CEGUI::Event::Subscriber(EventShowTrack));

		//发射卫星的Button
		winMgr->getWindow("button_launch")->subscribeEvent(CEGUI::Window::EventMouseButtonDown,CEGUI::Event::Subscriber(EventLaunchSatellite));
		//近地轨道加速的Button
		winMgr->getWindow("button_speed_up")->subscribeEvent(CEGUI::Window::EventMouseButtonDown,CEGUI::Event::Subscriber(EventSpeedUp));
	}
	return ret_value;
}
コード例 #20
0
ファイル: startme.cpp プロジェクト: GameLemur/Crystal-Space
bool StartMe::Application()
{
  // Set up window transparency. Must happen _before_ system is opened!
  csRef<iGraphics2D> g2d = csQueryRegistry<iGraphics2D> (GetObjectRegistry ());
  if (!g2d) return ReportError ("Failed to obtain canvas!");
  natwin = scfQueryInterface<iNativeWindow> (g2d);
  if (natwin)
  {
    natwin->SetWindowTransparent (true);
  }

  // Open the main system. This will open all the previously loaded plug-ins.
  // i.e. all windows will be opened.
  if (!OpenApplication(GetObjectRegistry()))
    return ReportError("Error opening system!");

  // The window is open, so lets make it disappear! 
  if (natwin)
  {
    natwin->SetWindowDecoration (iNativeWindow::decoCaption, false);
    natwin->SetWindowDecoration (iNativeWindow::decoClientFrame, false);
  }

  // Now get the pointer to various modules we need. We fetch them
  // from the object registry. The RequestPlugins() call we did earlier
  // registered all loaded plugins with the object registry.
  g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
  if (!g3d) return ReportError("Failed to locate 3D renderer!");

  engine = csQueryRegistry<iEngine> (GetObjectRegistry());
  if (!engine) return ReportError("Failed to locate 3D engine!");

  vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry());
  if (!vc) return ReportError("Failed to locate Virtual Clock!");

  kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry());
  if (!kbd) return ReportError("Failed to locate Keyboard Driver!");

  loader = csQueryRegistry<iLoader> (GetObjectRegistry());
  if (!loader) return ReportError("Failed to locate Loader!");

  vfs = csQueryRegistry<iVFS> (GetObjectRegistry());
  if (!vfs) return ReportError("Failed to locate VFS!");

  confman = csQueryRegistry<iConfigManager> (GetObjectRegistry());
  if (!confman) return ReportError("Failed to locate Config Manager!");

  cegui = csQueryRegistry<iCEGUI> (GetObjectRegistry());
  if (!cegui) return ReportError("Failed to locate CEGUI plugin");

  // Initialize the CEGUI wrapper
  cegui->Initialize ();
  
  // Let the CEGUI plugin take care of the rendering by itself
  cegui->SetAutoRender (true);
  
  // Set the logging level
  cegui->GetLoggerPtr ()->setLoggingLevel(CEGUI::Informative);

  vfs->ChDir ("/cegui/");

  // Load the 'ice' skin (which uses the Falagard skinning system)
  cegui->GetSchemeManagerPtr ()->create("ice.scheme");

  cegui->GetSystemPtr ()->setDefaultMouseCursor("ice", "MouseArrow");

  // Setup the fonts
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_NORMAL, 10, true, "/fonts/ttf/DejaVuSerif.ttf");
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_NORMAL_ITALIC, 10, true, "/fonts/ttf/DejaVuSerif-Italic.ttf");
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_TITLE, 15, true, "/fonts/ttf/DejaVuSerif-Bold.ttf");
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_TITLE_ITALIC, 15, true, "/fonts/ttf/DejaVuSerif-BoldItalic.ttf");

  CEGUI::WindowManager* winMgr = cegui->GetWindowManagerPtr ();

  // Load the CEGUI layout and set it as the root layout
  vfs->ChDir ("/data/startme/");
  cegui->GetSchemeManagerPtr ()->create ("crystal.scheme");
  cegui->GetSystemPtr ()->setGUISheet(winMgr->loadWindowLayout ("startme.layout"));

  // We need a View to the virtual world.
  view.AttachNew (new csView (engine, g3d));

  LoadConfig ();

  CEGUI::Window* logo = winMgr->getWindow("Logo");
  logo->subscribeEvent(CEGUI::Window::EventMouseClick,
      CEGUI::Event::Subscriber(&StartMe::OnLogoClicked, this));

  ///TODO: Using 'EventMouseEntersArea' is more correct but is only available 
  /// in 0.7.2+
  logo->subscribeEvent(CEGUI::Window::EventMouseEnters,
      CEGUI::Event::Subscriber(&StartMe::OnEnterLogo, this));
  logo->subscribeEvent(CEGUI::Window::EventMouseLeaves,
      CEGUI::Event::Subscriber(&StartMe::OnLeaveLogo, this));

  vfs->ChDir ("/lib/startme");

  CEGUI::Window* root = winMgr->getWindow("root");

  for (size_t i = 0 ; i < demos.GetSize () ; i++)
  {
    demos[i].window = winMgr->createWindow("crystal/Icon");
    demos[i].window->setSize(CEGUI::UVector2(CEGUI::UDim(0.0f, 128.0f), CEGUI::UDim(0.0f, 128.0f)));
    demos[i].window->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(0.0f, 0.0f)));
    demos[i].window->setVisible(false);

    CEGUI::ImagesetManager* imsetmgr = cegui->GetImagesetManagerPtr();
    if (!imsetmgr->isDefined(demos[i].image))
      imsetmgr->createFromImageFile(demos[i].image, demos[i].image);
    std::string img = "set:"+std::string(demos[i].image)+" image:full_image";
    demos[i].window->setProperty("Image", img);

    root->addChildWindow(demos[i].window);

    demos[i].window->subscribeEvent(CEGUI::Window::EventMouseClick,
      CEGUI::Event::Subscriber(&StartMe::OnClick, this));
  }

  // Initialize the starting position of the demo wheel to a random value
  csRandomFloatGen frandomGenerator;
  position = frandomGenerator.Get (demos.GetSize () - 1);

  // Let the engine prepare everything
  engine->Prepare ();
  printer.AttachNew (new FramePrinter (object_reg));

  // This calls the default runloop. This will basically just keep
  // broadcasting process events to keep the application going on.
  Run();

  return true;
}
コード例 #21
0
bool SelectorHelper::ShowLeaderboard( const CEGUI::EventArgs &e ) {
  CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr();
  CEGUI::Window* leaderboardWindow, *leaderboardName, *leaderboardNextLevel, *leaderboardBackToMenu;
  CEGUI::Window* leaderboardWindows[10];

  leaderboardWindow = wmgr->getWindow("Leaderboard");
  leaderboardName = wmgr->getWindow("Leaderboard/LevelName");
  leaderboardNextLevel = wmgr->getWindow("Leaderboard/NextLevel");
  leaderboardBackToMenu = wmgr->getWindow("Leaderboard/BackToMenu");

  for (int i = 0; i < 10; i++) {
    std::stringstream ss;
    ss << "Leaderboard/" << i;
    leaderboardWindows[i] = wmgr->getWindow(ss.str());
  }

  CEGUI::System::getSingleton().setGUISheet(leaderboardWindow);

  leaderboardBackToMenu->removeEvent(CEGUI::PushButton::EventClicked);
  leaderboardBackToMenu->subscribeEvent(CEGUI::PushButton::EventClicked,
                                        &SelectorHelper::SwitchToLevelSelectMenu);

  int levelViewerIndex =
    *static_cast<const CEGUI::MouseEventArgs*>(&e)->window->getName().rbegin() - '1';

  CEGUI::String name = levelViewers[levelViewerIndex]->window->getName();

  leaderboardNextLevel->setVisible(false);

  /*
    leaderboardNextLevel->removeEvent(CEGUI::PushButton::EventClicked);
    leaderboardNextLevel
    ->subscribeEvent(CEGUI::PushButton::EventClicked,
    CEGUI::Event::Subscriber(&MenuActivity::awdawd, this));
  */


  for (int i = 0; i < 10; i++)
    leaderboardWindows[i]->setAlpha(0.0);

  Leaderboard leaderboard = Leaderboard::findLeaderboard(name.c_str());
  leaderboardName->setText(name.c_str());
  OBAnimationManager::startAnimation("SpinPopup", leaderboardName);
  OBAnimationManager::startAnimation("SpinPopup", leaderboardNextLevel, 0.5);
  OBAnimationManager::startAnimation("SpinPopup", leaderboardBackToMenu, 0.5);

  std::multimap<double, LeaderboardEntry, greater<double> > highscores = leaderboard.getHighscores();
  std::multimap<double, LeaderboardEntry>::iterator iter;

  int i = 0;
  for (iter = highscores.begin(); iter != highscores.end(); iter++) {
    LeaderboardEntry entry = iter->second;
    std::stringstream ss;

    size_t namelen = entry.name.length();
    ss << std::left << setw(55-namelen) << entry.name <<
      setw(15) << entry.score <<
      setw(15) << entry.getTimeTaken() <<
      setw(25) << entry.getTimeEntered();

    leaderboardWindows[i]->setText(ss.str());

    OBAnimationManager::startAnimation("FadeInFromLeft", leaderboardWindows[i], 1.0, 1.0 + 0.2f*i);
    i++;
  }
}
コード例 #22
0
void SelectorHelper::SwitchToLevelSelectMenu(void) {
  recycleViewers();

  CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr();
  CEGUI::Window *levelSelectorWindow = wmgr->getWindow("Menu/LevelSelector");

  if (CEGUI::System::getSingleton().getGUISheet()->getName().compare("Leaderboard") == 0) {
    CEGUI::System::getSingleton().setGUISheet(levelSelectorWindow);
    return;
  }

  // Pre-load windows
  LevelLoader *loader = LevelLoader::getSingleton();
  CEGUI::Window *lsBack = wmgr->getWindow("LevelSelector/Back");
  CEGUI::Window *lsPrev = wmgr->getWindow("LevelSelector/Prev");
  CEGUI::Window *lsNext = wmgr->getWindow("LevelSelector/Next");
  CEGUI::Window *lsButtons[8];

  for (int i = 0; i < 8; i++) {
    std::stringstream ss;
    ss << "LevelSelector/" << i+1;
    lsButtons[i] = wmgr->getWindow(ss.str());
  }

  lsPrev->removeEvent(CEGUI::PushButton::EventClicked);
  lsPrev->subscribeEvent(CEGUI::PushButton::EventClicked, &SelectorHelper::handleLSPrev);

  lsNext->removeEvent(CEGUI::PushButton::EventClicked);
  lsNext->subscribeEvent(CEGUI::PushButton::EventClicked, &SelectorHelper::handleLSNext);

  CEGUI::System::getSingleton().setGUISheet(levelSelectorWindow);

  // This variable ensures that viewers are only initiated once, then reused.
  static bool initViewers = false;

  // Load each level in level viewer
  int selectorEnd = selectorStart + 8; //(selectorRows*selectorColumns);

  for (int i = 0; i < 8; i++) {
    lsButtons[i]->setVisible(false);
    if (viewerPool.size() > i) {
      viewerPool[i]->window->setVisible(false);
    }
  }

  for (int i = selectorStart; i < selectorEnd && i < loader->levelNames.size(); i++) {
    LevelViewer *v;

    if (initViewers) {
      // Recycle your Level Viewers!
      if (viewerPool.empty()) break;
      v = viewerPool.back();
      viewerPool.pop_back();
      v->loadLevel(loader->levelNames[i].c_str());
      v->window->setVisible(true);

    } else {
      v = new LevelViewer(OgreBallApplication::getSingleton()->mRenderer, loader->levelNames[i].c_str());

    }

    levelSelectorWindow->addChildWindow(v->window);
    if(type_flag == TYPE_SINGLE_PLAYER || type_flag == TYPE_MULTI_HOST){
      MenuActivity *activity = (MenuActivity*) OgreBallApplication::getSingleton()->activity;

      lsBack->removeEvent(CEGUI::PushButton::EventClicked);
      lsBack->subscribeEvent(CEGUI::PushButton::EventClicked,
                             CEGUI::Event::Subscriber(&MenuActivity::SwitchToMainMenu, activity));

      if (type_flag == TYPE_SINGLE_PLAYER) {
        v->window->removeEvent(CEGUI::PushButton::EventMouseClick);
        v->window->subscribeEvent(CEGUI::PushButton::EventMouseClick,
                                  CEGUI::Event::Subscriber(&MenuActivity::StartSinglePlayer, activity));

        lsButtons[i % 8]->setVisible(true);
        lsButtons[i % 8]->removeEvent(CEGUI::PushButton::EventMouseClick);
        lsButtons[i % 8]->subscribeEvent(CEGUI::PushButton::EventMouseClick,
                                         &SelectorHelper::ShowLeaderboard);
      } else {
        v->window->removeEvent(CEGUI::PushButton::EventMouseClick);
        v->window->subscribeEvent(CEGUI::PushButton::EventMouseClick,
                                  CEGUI::Event::Subscriber(&MenuActivity::StartMultiPlayerHost, activity));
      }

    } else if (type_flag == TYPE_MULTI_CHANGE) {
      HostPlayerActivity *activity = (HostPlayerActivity*) OgreBallApplication::getSingleton()->activity;
      v->window->removeEvent(CEGUI::PushButton::EventMouseClick);
      v->window->subscribeEvent(CEGUI::PushButton::EventMouseClick,
                                CEGUI::Event::Subscriber(&HostPlayerActivity::handleLevelSelected, activity));
    }

    v->setPositionPercent(0.05 + ((i%8)%selectorColumns)*0.9/selectorColumns,
                          0.2 + ((i%8)/selectorColumns)*0.6/selectorRows);

    levelViewers.push_back(v);
  }

  initViewers = true;
}
コード例 #23
0
ファイル: ceguitest.cpp プロジェクト: GameLemur/Crystal-Space
bool CEGUITest::Application()
{
  if (!OpenApplication(GetObjectRegistry()))
    return ReportError("Error opening system!");

  vfs = csQueryRegistry<iVFS> (GetObjectRegistry());
  if (!vfs) return ReportError("Failed to locate VFS!");

  g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
  if (!g3d) return ReportError("Failed to locate 3D renderer!");

  engine = csQueryRegistry<iEngine> (GetObjectRegistry());
  if (!engine) return ReportError("Failed to locate 3D engine!");

  vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry());
  if (!vc) return ReportError("Failed to locate Virtual Clock!");

  kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry());
  if (!kbd) return ReportError("Failed to locate Keyboard Driver!");

  loader = csQueryRegistry<iLoader> (GetObjectRegistry());
  if (!loader) return ReportError("Failed to locate Loader!");

  cegui = csQueryRegistry<iCEGUI> (GetObjectRegistry());
  if (!cegui) return ReportError("Failed to locate CEGUI plugin");

  // Initialize CEGUI wrapper
  cegui->Initialize ();
  
  /* Let CEGUI plugin install an event handler that takes care of rendering
     every frame */
  cegui->SetAutoRender (true);
  
  // Set the logging level
  cegui->GetLoggerPtr ()->setLoggingLevel(CEGUI::Informative);

  vfs->ChDir ("/cegui/");

  // Load the ice skin (which uses Falagard skinning system)
  cegui->GetSchemeManagerPtr ()->create("ice.scheme");

  cegui->GetSystemPtr ()->setDefaultMouseCursor("ice", "MouseArrow");

  cegui->GetFontManagerPtr ()->createFreeTypeFont("DejaVuSans", 10, true, "/fonts/ttf/DejaVuSans.ttf");

  CEGUI::WindowManager* winMgr = cegui->GetWindowManagerPtr ();

  // Load layout and set as root
  vfs->ChDir ("/ceguitest/");
  cegui->GetSystemPtr ()->setGUISheet(winMgr->loadWindowLayout("ice.layout"));

  // Subscribe to the clicked event for the exit button
  CEGUI::Window* btn = winMgr->getWindow("Demo7/Window1/Quit");
  btn->subscribeEvent(CEGUI::PushButton::EventClicked,
    CEGUI::Event::Subscriber(&CEGUITest::OnExitButtonClicked, this));

  // These are used store the current orientation of the camera.
  rotY = rotX = 0;

  view.AttachNew(new csView (engine, g3d));
  iGraphics2D* g2d = g3d->GetDriver2D ();
  view->SetRectangle(0, 0, g2d->GetWidth(), g2d->GetHeight ());

  printer.AttachNew (new FramePrinter (object_reg));

  CreateRoom();
  view->GetCamera()->SetSector (room);
  view->GetCamera()->GetTransform().SetOrigin(csVector3 (0, 5, 0));

  Run();

  return true;
}