Esempio n. 1
0
		//! Reads attributes of the element
		void CGUISpinBox::deserializeAttributes(io::IAttributes * in, io::SAttributeReadWriteOptions * options)
		{
			IGUIElement::deserializeAttributes(in, options);
			setRange(in->getAttributeAsFloat("Min"), in->getAttributeAsFloat("Max"));
			setStepSize(in->getAttributeAsFloat("Step"));
			setDecimalPlaces(in->getAttributeAsInt("DecimalPlaces"));
		}
void QmitkNumberPropertyView::initialize()
{ // only to be called from constructors
  m_Suffix = "";
  m_DisplayFactor = 1.0;
  //setDecimalPlaces(-1); // unlimited
  setDecimalPlaces(2);
}
Esempio n. 3
0
void KLocale::setDecimalPlaces(int digits)
{
    d->setDecimalPlaces(digits);
}
QWidget* QmitkPropertyViewFactory::CreateEditor(mitk::BaseProperty* property, unsigned int type, QWidget* parent)
{
  if (!property) return nullptr;

  if ( mitk::StringProperty* prop = dynamic_cast<mitk::StringProperty*>(property) )
  {
    switch (type)
    {
      case etON_DEMAND_EDIT:
        // a string property
        return new QmitkStringPropertyOnDemandEdit(prop, parent);
      default:
        // a string property
        return new QmitkStringPropertyEditor(prop, parent);
    }
  }
  else if ( mitk::ColorProperty* prop = dynamic_cast<mitk::ColorProperty*>(property) )
  {
    // a color property
    return new QmitkColorPropertyEditor(prop, parent);
  }
  else if ( mitk::BoolProperty* prop = dynamic_cast<mitk::BoolProperty*>(property) )
  {
    // a bool property
    // TODO fix after refactoring
    auto  widget = new QmitkBoolPropertyWidget(parent);
    widget->SetProperty(prop);
    return widget;
  }
  else if ( mitk::IntProperty* prop = dynamic_cast<mitk::IntProperty*>(property) )
  {
    // a number property
    return new QmitkNumberPropertyEditor(prop, parent);
  }
  else if ( mitk::FloatProperty* prop = dynamic_cast<mitk::FloatProperty*>(property) )
  {
    // a number property
    auto  pe = new QmitkNumberPropertyEditor(prop, parent);
    pe->setDecimalPlaces(2);
    return pe;
  }
  else if ( mitk::DoubleProperty* prop = dynamic_cast<mitk::DoubleProperty*>(property) )
  {
    // a number property
    auto  pe = new QmitkNumberPropertyEditor(prop, parent);
    pe->setDecimalPlaces(2);
    return pe;
  }
  else if ( mitk::EnumerationProperty* prop = dynamic_cast<mitk::EnumerationProperty*>(property) )
  {
    // a enumeration property
    auto  pe = new QmitkEnumerationPropertyWidget(parent);
    pe->SetProperty(prop);
    return pe;
  }
  else
  {
    // some unknown property --> no editor possible
    return nullptr;
  }
}
	void CMazeGameMenu::init(irr::gui::IGUIEnvironment * const in_guiEnv, const irr::core::recti & in_menuRect)
	{
		//TODO: Add cool images as buttons.
		LOG(DEBUG) << "Initializing menu";
		_mainMenuElements.clear();
		_gameSettingsElements.clear();
		_videoSettingsElements.clear();
		_guiEnv = in_guiEnv;
		auto backgroundImg = in_guiEnv->addImage(irr::core::recti(irr::core::vector2di(0, 0), in_guiEnv->getVideoDriver()->getScreenSize()));
		backgroundImg->setScaleImage(true);
		backgroundImg->setColor(irr::video::SColor(150, 255, 255, 255));
		backgroundImg->setImage(in_guiEnv->getVideoDriver()->getTexture("../media/p-of-eternity-maze-by-malcolm.jpg"));
		auto backImg = in_guiEnv->addImage(irr::core::recti(
			irr::core::vector2di(in_menuRect.UpperLeftCorner.X * (1.0f - ElementSeparationRatio), in_menuRect.UpperLeftCorner.Y * (1.0f - ElementSeparationRatio)), 
			irr::core::dimension2di(in_menuRect.getSize().Width *(1.0f + ElementSeparationRatio), in_menuRect.getSize().Height *(1.0f + ElementSeparationRatio + ElementHeightRatio))), backgroundImg);
		backImg->setScaleImage(true);
		backImg->setColor(irr::video::SColor(200, 255, 255, 255));
		backImg->setImage(in_guiEnv->getVideoDriver()->getTexture("../media/irrlicht2_up.jpg"));
		_menuBackground = backgroundImg;
		in_guiEnv->getSkin()->setFont(in_guiEnv->getFont("../media/fonthaettenschweiler.bmp"));
		//set the main menu.
		auto in_videoDriver = in_guiEnv->getVideoDriver();
		irr::core::dimension2di elementSize = in_menuRect.getSize(); 
		elementSize.Height *= ElementHeightRatio;
		int elementSeperation = in_menuRect.getHeight() * ElementSeparationRatio;
		irr::core::vector2di elementPosition(in_menuRect.UpperLeftCorner);
		auto button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::BackToGameBtn,L"Back to Game");
		//button->setImage(in_videoDriver->getTexture("../media/backToGame.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::NewGameBtn, L"New Game");
		//button->setImage(in_videoDriver->getTexture("../media/newGame.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::GameSettingsBtn, L"Game Settings");
		//button->setImage(in_videoDriver->getTexture("../media/gameSettings.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::VideoSettingsBtn, L"Video Settings");
		//button->setImage(in_videoDriver->getTexture("../media/videoSettings.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::QuitBtn, L"Quit");
		//button->setImage(in_videoDriver->getTexture("../media/quitGame.jpg"));
		_mainMenuElements.push_back(button);
		//set the video settings menu
		elementPosition.Y = in_menuRect.UpperLeftCorner.Y;
		auto resImage = in_guiEnv->addImage(irr::core::recti(elementPosition, elementSize));
		resImage->setText(L"Select the desired resolution");
		//resImage->setImage(in_videoDriver->getTexture("../media/Resolution.jpg"));
		_videoSettingsElements.push_back(resImage);
		elementPosition.Y += elementSeperation + elementSize.Height;
		auto listBox = in_guiEnv->addListBox(irr::core::recti(elementPosition, irr::core::dimension2di(elementSize.Width,in_menuRect.getHeight()- (elementSize.Height + 2.0f * elementSeperation))), nullptr, MenuElement::ResolutionDropDown, true);
		listBox->addItem(L"800x600");
		listBox->addItem(L"1024x768");
		listBox->addItem(L"1200x1600");
		listBox->setSelected(0);
		_videoSettingsElements.push_back(listBox);
		//add buttons at the bottom to both game and setting menu
		elementPosition.Y = in_menuRect.UpperLeftCorner.Y + in_menuRect.getHeight();
		elementSize.Width = (elementSize.Width - elementSeperation) / 2.0f;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::BackToMainMenuBtn, L"Back to Main Menu");
		//button->setImage(in_videoDriver->getTexture("../media/backToMainMenu.jpg"));
		_videoSettingsElements.push_back(button);
		_gameSettingsElements.push_back(button);
		elementPosition.X += elementSize.Width + elementSeperation;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::SetVideoSettingsBtn, L"Apply (restart game)");
		//button->setImage(in_videoDriver->getTexture("../media/setVideoSettings.jpg"));
		_videoSettingsElements.push_back(button);
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::SetGameSettingsBtn, L"Apply (restart game)");
		//button->setImage(in_videoDriver->getTexture("../media/setGameSettings.jpg"));
		_gameSettingsElements.push_back(button);
		//set the game settings menu
		elementPosition.Y = in_menuRect.UpperLeftCorner.Y;
		auto spinBox = in_guiEnv->addSpinBox(L"Number of AI players", irr::core::recti(elementPosition, elementSize),true,nullptr,MenuElement::MazeNumOfAI);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(0.0f, 10.0f);
		spinBox->setValue(3.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition.Y += elementSeperation + elementSize.Height;
		spinBox = in_guiEnv->addSpinBox(L"AI level", irr::core::recti(elementPosition, elementSize), true, nullptr, MenuElement::MazeAIDifficultyLevel);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(1.0f, 10.0f);
		spinBox->setValue(3.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition.Y += elementSeperation + elementSize.Height;
		spinBox = in_guiEnv->addSpinBox(L"Maze Width", irr::core::recti(elementPosition, elementSize), true, nullptr, MenuElement::MazeWidth);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(20.0f, 60.0f);
		spinBox->setStepSize(2.0f);
		spinBox->setValue(30.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition.Y += elementSeperation + elementSize.Height;
		spinBox = in_guiEnv->addSpinBox(L"Maze Height", irr::core::recti(elementPosition, elementSize), true, nullptr, MenuElement::MazeHeight);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(20.0f, 60.0f);
		spinBox->setStepSize(2.0f);
		spinBox->setValue(30.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition = in_menuRect.UpperLeftCorner;
		_gameSettingsElements.push_back( in_guiEnv->addStaticText(L"Number of AI players:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;
		_gameSettingsElements.push_back(in_guiEnv->addStaticText(L"AI Level:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;
		_gameSettingsElements.push_back(in_guiEnv->addStaticText(L"Maze Width:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;
		_gameSettingsElements.push_back(in_guiEnv->addStaticText(L"Maze Length:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;

		//hide all menu elements
		setMenuEnabled(false, _mainMenuElements);
		setMenuEnabled(false, _gameSettingsElements);
		setMenuEnabled(false, _videoSettingsElements);
		_menuBackground->setVisible(false);
		_currentMenu = CurrentMenu::None;

		LOG(DEBUG) << "Finished initializing menu";
	}