Exemplo n.º 1
0
	//! Reads attributes of the element
	void CGUIButton::deserializeAttributes(IAttributes* in, SAttributeReadWriteOptions* options = 0)
	{
		IGUIButton::deserializeAttributes(in, options);

		IsPushButton = in->getAttributeAsBool("PushButton");
		Pressed = IsPushButton ? in->getAttributeAsBool("Pressed") : false;

		rect<SINT32> rec = in->getAttributeAsRect("ImageRect");
		if (rec.isValid())
			setImage(in->getAttributeAsTexture("Image"), rec);
		else
			setImage(in->getAttributeAsTexture("Image"));

		rec = in->getAttributeAsRect("PressedImageRect");
		if (rec.isValid())
			setPressedImage(in->getAttributeAsTexture("PressedImage"), rec);
		else
			setPressedImage(in->getAttributeAsTexture("PressedImage"));

		setDrawBorder(in->getAttributeAsBool("Border"));
		setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel"));
		setScaleImage(in->getAttributeAsBool("ScaleImage"));

		//   setOverrideFont(in->getAttributeAsString("OverrideFont"));

		updateAbsolutePosition();
	}
Exemplo n.º 2
0
    //-----------------------------------------------------------------------
    //                 d e s e r i a l i z e A t t r i b u t e s
    //-----------------------------------------------------------------------
    void TGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
    {
        IGUIImage::deserializeAttributes(in,options);

        setImage(in->getAttributeAsTexture("Texture"));
        setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel"));
        setColor(in->getAttributeAsColor("Color"));
        setScaleImage(in->getAttributeAsBool("ScaleImage"));
    }
Exemplo n.º 3
0
//! Reads attributes of the element
void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
	IGUIImage::deserializeAttributes(in,options);

	setImage(in->getAttributeAsTexture("Texture", Texture));
	setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel", UseAlphaChannel));
	setColor(in->getAttributeAsColor("Color", Color));
	setScaleImage(in->getAttributeAsBool("ScaleImage", UseAlphaChannel));
	setSourceRect(in->getAttributeAsRect("SourceRect", SourceRect));

	DrawBounds.UpperLeftCorner.X = in->getAttributeAsFloat("DrawBoundsX1", DrawBounds.UpperLeftCorner.X);
	DrawBounds.UpperLeftCorner.Y = in->getAttributeAsFloat("DrawBoundsY1", DrawBounds.UpperLeftCorner.Y);
	DrawBounds.LowerRightCorner.X = in->getAttributeAsFloat("DrawBoundsX2", DrawBounds.LowerRightCorner.X);
	DrawBounds.LowerRightCorner.Y = in->getAttributeAsFloat("DrawBoundsY2", DrawBounds.LowerRightCorner.Y);
	setDrawBounds(DrawBounds);
}
Exemplo n.º 4
0
//! Reads attributes of the element
void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
	IGUIButton::deserializeAttributes(in,options);

	IsPushButton = in->getAttributeAsBool("PushButton", IsPushButton);
	Pressed		 = IsPushButton ? in->getAttributeAsBool("Pressed", Pressed) : false;

	for ( u32 i=0; i<(u32)EGBIS_COUNT; ++i )
	{
		core::stringc nameRect( GUIButtonImageStateNames[i] );
		nameRect += "Rect";

		setImage((EGUI_BUTTON_IMAGE_STATE)i,
				in->getAttributeAsTexture(GUIButtonImageStateNames[i], ButtonImages[i].Texture),
				in->getAttributeAsRect(nameRect.c_str(), ButtonImages[i].SourceRect) );
	}

	setDrawBorder(in->getAttributeAsBool("Border", DrawBorder));
	setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel", UseAlphaChannel));
	setScaleImage(in->getAttributeAsBool("ScaleImage", ScaleImage));

	for ( u32 i=0; i<(u32)EGBS_COUNT; ++i )
	{
		core::stringc nameIndex( GUIButtonStateNames[i] );
		nameIndex += "Index";
		ButtonSprites[i].Index = in->getAttributeAsInt(nameIndex.c_str(), ButtonSprites[i].Index );

		core::stringc nameColor( GUIButtonStateNames[i] );
		nameColor += "Color";
		ButtonSprites[i].Color = in->getAttributeAsColor(nameColor.c_str(), ButtonSprites[i].Color );

		core::stringc nameLoop( GUIButtonStateNames[i] );
		nameLoop += "Loop";
		ButtonSprites[i].Loop = in->getAttributeAsBool(nameLoop.c_str(), ButtonSprites[i].Loop );

		core::stringc nameScale( GUIButtonStateNames[i] );
		nameScale += "Scale";
		ButtonSprites[i].Scale = in->getAttributeAsBool(nameScale.c_str(), ButtonSprites[i].Scale );
	}

	//   setOverrideFont(in->getAttributeAsString("OverrideFont"));

	updateAbsolutePosition();
}
Exemplo n.º 5
0
	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";
	}