Пример #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
//-------------------------------------------------------------------------------------
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;
}
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; 
}
Пример #4
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);
}
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);
}
//近地点加速
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;
}
Пример #7
0
//-------------------------------------------------------------------------------------
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;
}
Пример #8
0
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;
}
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:"));
}
Пример #10
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;
}
Пример #11
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++;
  }
}
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;
}
Пример #13
0
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;
}