示例#1
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);
  }
}
示例#3
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;
  }

}
示例#4
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);
    }
  }
}