Example #1
0
	void LobbyState::init()
	{
		mGfx = dynamic_cast<OgreSubsystem*>(mEngine->getSubsystem("OgreSubsystem"));
		mAudio = dynamic_cast<ALSubsystem*>(mEngine->getSubsystem("ALSubsystem"));
		mInput = dynamic_cast<OISSubsystem*>(mEngine->getSubsystem("OISSubsystem"));
		mScript = dynamic_cast<LuaSubsystem*>(mEngine->getSubsystem("LuaSubsystem"));
		mInput->initInput(mGfx->getWindowHandle(), true);
		mGfx->setBackgroundColor(Colour(0.3f,0.5f,0.7f));

		GUI* gui = mGfx->getGUI();
		GUIScreen* scrn = mGfx->getGUI()->createScreen(mGfx->getMainViewport(),"TechDemo","Test");
		mScreen = scrn;
		scrn->getRootElement(0)->setAspectRatio(4,3);
		mGfx->getGUI()->setOverlayEnabled("HUD", false);

		// set up cursor
		GUIRectangle* rect = new GUIRectangle(scrn->getRootElement(8),"cursor","Mouse");
		rect->setScale(Vector2(16.f/1024.f,23.f/768.f));
		scrn->setCursor(rect);

		// hook up the input and the GUI
		EventHandler::getDestination("OISSubsystem")->getSignal("mouseMovedAbs")
			->addListener(scrn->getSlot("moveCursor"));
		EventHandler::getDestination("OISSubsystem")->getSignal("pressed_MB_Left")
			->addListener(scrn->getSlot("click"));
		EventHandler::getDestination("OISSubsystem")->getSignal("released_MB_Left")
			->addListener(scrn->getSlot("release"));

		StaticText* txt = new StaticText(scrn->getRootElement(0),
			"Title",0,20,Vector2(0.4f,0.2f),Vector2(0.2,1.f/20.f),"New Game");
		createSlot("play", this, &LobbyState::clickedStart);
		txt->setColour(Colour(1.f,1.f,1.f));
		txt->setAlign(GA_CENTER);

		rect = new GUIRectangle(scrn->getRootElement(0),"button","logo");
		rect->setScale(Vector2(327.f/1024.f,80.f/768.f));
		rect->setPosition(Vector2(-0.01f,0.9f));

		// labels
		txt = new StaticText(scrn->getRootElement(0),"modelabel",0,20,Vector2(0.4f,0.27f),
			Vector2(0.2,1.f/20.f),"Mode: ");
		txt->setColour(Colour(1.f,1.f,1.f));
		txt->setScale(Vector2(327.f/1024.f,32.f/768.f));
		txt->setPosition(Vector2(0.2705f,0.492f));
		txt = new StaticText(scrn->getRootElement(0),"difflabel",0,20,Vector2(0.4f,0.27f),
			Vector2(0.2,1.f/20.f),"Difficulty: ");
		txt->setColour(Colour(1.f,1.f,1.f));
		txt->setScale(Vector2(327.f/1024.f,32.f/768.f));
		txt->setPosition(Vector2(0.2705f,0.552f));

		addButton(Vector2(412.f/1024.f, 0.4f), "Go!", "play");
		addButton(Vector2(412.f/1024.f, 0.48f), "< Classic >", "play");
		addButton(Vector2(412.f/1024.f, 0.54f), "< Easy >", "play");
		addButton(Vector2(412.f/1024.f, 0.62f), "Back", "play");



	}
Example #2
0
void E_scene_main_game::actionPerformed(GUIEvent &evt)
{
	
	
	const std::string &callbackString  = evt.getCallbackString();
	GUIRectangle      *sourceRectangle = evt.getEventSource();
	int                widgetType      = sourceRectangle->getWidgetType();

	if(widgetType == WT_BUTTON)
	{
		GUIButton   *button = (GUIButton*)sourceRectangle;
		if(button->isClicked())
		{
			
			if(callbackString == "QuitMainGame")
			{
				scene_to_go=GAME_SCENE_MAIN_MENU;
				init_fade_in();
				fade_in=true;
			}
			
			if (callbackString == "ResetCamera")
			{
				chessboard->resetCameraPos();
			}
			
			if (callbackString == "okButtonPromotion")
			{
				player_do_a_move(piece_for_promotion);
				pGlobalInfos->GUI_displayPromotion(false);
				promotion=false;
			}
		}
	}
	else if (widgetType == WT_RADIO_BUTTON)
	{
		GUIRadioButton *button = (GUIRadioButton*)sourceRectangle;
		
		if(button->isClicked())
		{
			
			if(callbackString == "queen")
				piece_for_promotion='q';
			
			if(callbackString == "rook")
				piece_for_promotion='r';
			
			if(callbackString == "bishop")
				piece_for_promotion='b';
			
			if(callbackString == "knight")
				piece_for_promotion='n';
		}
		
	}
}
void MainMenuScene::actionPerformed(GUIEvent &evt)
{
  const String &callbackString  = evt.getCallbackString();
  GUIRectangle *sourceRectangle = evt.getEventSource();
  int           widgetType      = sourceRectangle->getWidgetType();
  
  if (widgetType == BUTTON)
  {
    GUIButton *button = (GUIButton*) sourceRectangle;
    
    if (button->isClicked())
      sceneController.execute(callbackString);
  }
}
Example #4
0
void EventsHandler::actionPerformed(GUIEvent &evt)
{
static int num  = 0;
  const std::string &callbackString  = evt.getCallbackString();
  GUIRectangle      *sourceRectangle = evt.getEventSource(),
                    *parent          = sourceRectangle ? sourceRectangle->getParent() : NULL;
  int                widgetType      = sourceRectangle->getWidgetType();

  if(widgetType == WT_SLIDER )
  {
    GUISlider  *slider = (GUISlider*)sourceRectangle;
    if(callbackString == "s1" || callbackString == "s2")
    {
      sprintf(charBuffer, "%s: %.2f",  (callbackString == "s1") ? "Slider 1" : "Slider 2",  slider->getProgress());
      slider->setLabelString(charBuffer);
    }

    if(callbackString == "red")   red   = slider->getProgress();
    if(callbackString == "blue")  blue  = slider->getProgress();
    if(callbackString == "green") green = slider->getProgress();
  }

  if(widgetType == WT_BUTTON)
  {
    GUIButton   *button = (GUIButton*)sourceRectangle;
    if(callbackString == "exit")
      if(button->isClicked())
        exit(0);
  }

  if(widgetType == WT_COMBO_BOX)
  {
    GUIComboBox  *comboBox = (GUIComboBox*)sourceRectangle;
    if(callbackString == "cb1")
    if(comboBox->getSelectedItem() == std::string("Select this item to exit"))
      exit(0);
  }

  if(widgetType == WT_RADIO_BUTTON)
  {
    GUIRadioButton   *radioButton = (GUIRadioButton*)sourceRectangle;
  }

}
Example #5
0
void GUITabbedPanel::actionPerformed(GUIEvent &evt)
{
  GUIEventListener *eventsListener  = parent->getEventsListener();
  const NSString     &cbs             = evt.getCallbackString();
  GUIRectangle     *sourceRectangle = evt.getEventSource();
  int               widgetType      = sourceRectangle->getWidgetType();

  if((widgetType == BUTTON) && sourceRectangle->isPressed())
  {
    const Widgets &widgets = lowerPanel->getWidgets(),
                  &buttons = upperPanel->getWidgets();
    int   target = atoi(sourceRectangle->getCallbackString()),
          count  = int(widgets.size());
    for(int t = 0; t < count; t++)
    {
      widgets[t]->setVisible(t == target);
      ((GUIAlphaElement*)buttons[t])->setMinAlpha((t == target) ? 1.0f : 0.5f);
    }
  }
}