Esempio n. 1
0
	void Button::deactivate()
	{
		Component::deactivate();

		if (isToggle_)
		{
			if (isSelected())
				changeTexture(Selected);
			else
				changeTexture(Normal);
		}
	}
Esempio n. 2
0
int GameUI::update(core::Siika2D *siika, Boss *boss)
{

	if (ushiko.health < heartCount)
		changeTexture(heartIcons[ushiko.health], siika, "ui_heart_hurt.png",glm::vec2(64,64));
	else if (ushiko.health > heartCount)
		changeTexture(heartIcons[ushiko.health - 1], siika, "ui_heart_pink.png", glm::vec2(64, 64));

	heartCount = ushiko.health;

	if (boss != nullptr && boss->bossHealth != bossHeartCount)
	{
		changeTexture(bossHeartIcons[boss->bossHealth], siika, "ui_bosslifebar_hearthurt.png", glm::vec2(64, 64));
		bossHeartCount = boss->bossHealth;
	}
	if (boss == nullptr)
	{
		std::stringstream pointsText;
		pointsText << ushiko.pointsAmount << "/" << levelPoints;
		pointsTextUI->setText(pointsText.str());
	}

	glm::vec2 touchPosition = glm::vec2(0, 0);
	if (inputTimer.getElapsedTime(SECONDS) > 0.5)
	{
		for (int i = 0; i < siika->_input->touchPositionsActive(); i++)
			touchPosition = siika->_input->touchPosition(i)._positionStart;
		
		if (isIntersecting(touchPosition, pauseButton->getComponent<misc::TransformComponent>()->getPosition()))
		{
			inputTimer.reset();

			if (lastState == RESUME)
			{
				changeTexture(pauseButton, siika, "ui_playbutton.png", glm::vec2(128,128));
				shade->setPosition(glm::vec2(0, 0));

				lastState = PAUSE;
				return PAUSE;
			}
			else
			{
				changeTexture(pauseButton, siika, "ui_pausebutton.png", glm::vec2(128, 128));
				shade->setPosition(glm::vec2(0, siika->_graphicsContext->getDisplaySize().y));

				lastState = RESUME;
				return RESUME;
			}
		}
	}
	return DEFAULT;
}
void Button::deactivate()
{
	Component::deactivate();

	if (mIsToggle)
	{
        // Reset texture to right one depending on if we are selected or not.
		if (isSelected())
			changeTexture(Selected);
		else
			changeTexture(Normal);
	}
}
Esempio n. 4
0
void Button::select()
{
    Widget::select();
    changeTexture(Type::Selected);

    soundPlayer.play(SoundEffects::ID::ButtonHover);
}
Esempio n. 5
0
void OptionDialog::chooseColor()
{
  QColor color = QColorDialog::getColor(m_color, 0, tr("Choose background color"));
  if (color.isValid() && color.rgb() != m_color)
    m_color = color.rgb();
  changeTexture(true);
}
Esempio n. 6
0
OptionDialog::OptionDialog (QWidget *parent) : QDialog(parent), m_color(qRgb(0,128,0))
{
  setupUi(this);
  changeTexture(true);
  connect(rbTexture0, SIGNAL(toggled(bool)), this, SLOT(changeTexture(bool)));
  connect(rbTexture1, SIGNAL(toggled(bool)), this, SLOT(changeTexture(bool)));
  connect(rbTexture2, SIGNAL(toggled(bool)), this, SLOT(changeTexture(bool)));
  connect(cbAnimTake, SIGNAL(stateChanged(int)), this, SLOT(toggleTakeQuality(int)));
}
Esempio n. 7
0
	Button::Button(State::Context context) :
		callback_(),
		sprite_(context.textures->resource(TextureId::Buttons)),
		text_("", context.fonts->resource(FontId::Regular)),
		isToggle_(false)
	{
		changeTexture(Normal);

		centerOrigin(sprite_);
	}
Esempio n. 8
0
void Button::activate()
{
    Widget::activate();
    changeTexture(Type::Pressed);

    if (callback)
        callback();

    deactivate();
    soundPlayer.play(SoundEffects::ID::ButtonClick);
}
Button::Button(const FontHolder& fonts, const TextureHolder& textures)
: mCallback()
, mSprite(textures.get(Textures::Buttons))
, mText("", fonts.get(Fonts::Main), 16)
, mIsToggle(false)
{
	changeTexture(Normal);

	sf::FloatRect bounds = mSprite.getLocalBounds();
	mText.setPosition(bounds.width / 2.f, bounds.height / 2.f);
}
Esempio n. 10
0
  Button::Button(State::Context context)
  : mCallback()
  , mSprite(context.textures->get(Textures::Buttons))
  , mText("", context.fonts->get(Fonts::Main), 16)
  , mIsToggle(false)
 // , mSounds(*context.sounds)
  {
      changeTexture(Normal);
      
      sf::FloatRect bounds = mSprite.getLocalBounds();
      mText.setPosition(bounds.width / 2.f, bounds.height / 2.f);
  }
Esempio n. 11
0
/*
sf::Packet& operator<<(sf::Packet& packet, const GameMap& gameMap)
{
	for (int i = 0; i < gameMap.MAP_HEIGHT; i++)
	{
		for (int j = 0; j < gameMap.MAP_WIDTH; j++)
		{
			int hold = gameMap.m_Map[i][j].getState();
			sf::Int8 sf_int_8(hold);
			packet << sf_int_8;
		}
	}
	return packet;
}

sf::Packet& operator>>(sf::Packet& packet, GameMap& gameMap)
{
	for (int i = 0; i < gameMap.MAP_HEIGHT; i++)
	{
		for (int j = 0; j < gameMap.MAP_WIDTH; j++)
		{
			sf::Int8 hold;
			packet >> hold;
			Boxstate newstate = static_cast<Boxstate>(hold);
			Box box(newstate);
			gameMap.m_Map[i][j] = box;
		}
	}
	return packet;
}
*/
void GameMap::changeTexture(Box& box, int layer)
{
	if (layer <= 0)
	{
		return;
	}

	//define the adjaceBoxes
	Box *adjacentBox[] = { &box - MAP_WIDTH,                                  //up
		&box + MAP_WIDTH,                                 //down
		&box - 1,    //left
		&box + 1,    //right
	};

	for (int i = 0; i < 4; i++)
	{
		if (adjacentBox[i]->getState() == Boxstate::occupied)
		{
			changeTexture(*adjacentBox[i], layer - 1);

			/*declare the hash value, initialize as 0.
			If the player also owns the top, the hash value +1
			If the player also owns the right, the hash value +5
			If the player also owns the bottom, the hash value +7
			If the player also owns the left, the hash value +9
			*/
			int hashAddress = 0;
			if (box.getOwner() != adjacentBox[0]->getOwner())
			{
				hashAddress += 1;
			}
			if (box.getOwner() != adjacentBox[3]->getOwner())
			{
				hashAddress += 5;
			}
			if (box.getOwner() != adjacentBox[1]->getOwner())
			{
				hashAddress += 7;
			}
			if (box.getOwner() != adjacentBox[2]->getOwner())
			{
				hashAddress += 9;
			}
			//change the texture according to the hash value

            std::string path = box.getOwner()->getTexturePath() + "22.png";
            
			box.setButtonTexture(&AssetManager::GetTexture(path), &AssetManager::GetTexture(path));
			box.change_texture_to_normal();
		}
	}
}
Esempio n. 12
0
	void Button::activate()
	{
		Component::activate();

		if (isToggle_)
			changeTexture(Pressed);

		if (callback_)
			callback_();

		if (!isToggle_)
			deactivate();
	}
Esempio n. 13
0
void BrickBonus::animationDestroy()
{
	if (_type == EWALL)
	{
		_sprite->stopActionByTag(BLINK_TAG);
		_sprite->setColor(_oldColor);
		changeTexture(EBACKGROUND);
		_type = EBONUS;
	}
	if (!createBonus())
	{	
		animateDestroyBonus();
	}
}
Esempio n. 14
0
 Button::Button(const TextureHolder& textures)
 : mCallback()
 , mSprite(textures.get(TagDefaults::Textures::Buttons))
 , mText("", getGUISettings().fonts->get(getGUISettings().buttonFont), 16)
 , mIsToggle(false)
 {
     mButtonWidth = mSprite.getTexture()->getSize().x;
     mButtonHeight = (mSprite.getTexture()->getSize().y/3);
     
     changeTexture(Normal);
     
     sf::FloatRect bounds = mSprite.getLocalBounds();
     mText.setPosition(bounds.width / 2.f, bounds.height / 2.f);
 }
Esempio n. 15
0
void OptionDialog::setBackgroundType(const int type)
{
  switch (type) {
    case 0:
      rbTexture0->toggle();
      break;
    case 1:
      rbTexture1->toggle();
      break;
    case 2:
      rbTexture2->toggle();
      break;
  }
  changeTexture(true);
}
void Button::activate()
{
	Component::activate();

    // If we are toggle then we should show that the button is pressed and thus "toggled".
	if (mIsToggle)
		changeTexture(Pressed);

	if (mCallback)
		mCallback();

    // If we are not a toggle then deactivate the button since we are just momentarily activated.
	if (!mIsToggle)
		deactivate();
}
Esempio n. 17
0
void Renderer::apply(){
	changeShader(selectedShader);

	assignNamedTextures();

	for (int textureUnit = 0; textureUnit < nSimultaneousTextures; textureUnit++){
		changeTextureUnit(textureUnit);
		changeTexture(selectedTextures[textureUnit]);
		changeTexEnv(selectedColorTexEnvs[textureUnit], selectedAlphaTexEnvs[textureUnit]);
	}

	changeBlending(selectedSrcFactor, selectedDestFactor, selectedBlendMode);
	changeDepthFunc(selectedDepthFunc);
	changeMask(selectedMask);

	reset();
}
Esempio n. 18
0
 void Button::activate()
 {
     Component::activate();
     
     // If we are a toggle then we should show that the button is pressed and thus "toggle"
     if(mIsToggle)
     {
         changeTexture(Pressed);
     }
     
     if(mCallback)
     {
         mCallback();
     }
     
     // If we are not a toggle then deactivate the button since we are just momentarily activated.
     if(!mIsToggle)
     {
         deactivate();
     }
     
     getGUISettings().sounds->play(getGUISettings().buttonPressedSound);
 }
Esempio n. 19
0
void Button::deactivate()
{
    Widget::deactivate();
    changeTexture(Type::Selected);
}
void Button::deselect()
{
	Component::deselect();

	changeTexture(Normal);
}
void Button::select()
{
	Component::select();

	changeTexture(Selected);
}
Esempio n. 22
0
void Button::setTexture(const sf::Texture &texture)
{
    sprite.setTexture(texture);
    changeTexture(Type::Normal);
    centerText();
}
Esempio n. 23
0
void Button::deselect()
{
    Widget::deselect();
    changeTexture(Type::Normal);
}
Esempio n. 24
0
bool GameMap::captureBox(const Box& newBox, const sf::Vector2i &mouseposition)
{
    //get the reference of the box
    Box& targetBox = getCurrentBox(mouseposition);
    
    //if the box is not capturable, return false
    if(!targetBox.isCapturable())
    {
        return false;
    }
    
    //copy the newBox to the target
    targetBox = newBox;

	//add score to that player
	targetBox.getOwner()->addScore(targetBox.getScore());
    
    //decrement of avilable box
    available_Box--;
    
	//define the adjaceBoxes
	Box *adjacentBox[] = { &targetBox - MAP_WIDTH,                                  //up
		&targetBox + MAP_WIDTH,                                 //down
		&targetBox - 1,    //left
		&targetBox + 1,    //right
		
		&targetBox - MAP_WIDTH - 1,//left top
		&targetBox + MAP_WIDTH - 1,//left bottom
		&targetBox - MAP_WIDTH + 1,//right top
		&targetBox + MAP_WIDTH + 1//right bottom
		
	};

	//check the surroundings...
	for (int i = 0; i < 8; i++)
	{
		if (adjacentBox[i]->getState() == Boxstate::occupied)
		{
			//if it is the same owner, fortify and change the texture
			if (adjacentBox[i]->getOwner() == targetBox.getOwner())
			{
				//fortify...
                adjacentBox[i]->setScore(adjacentBox[i]->getScore() + 3);
				}
			//else, if the targetBox.score > adjacentBox[i], capture that box
			else
			{
				if (targetBox.getScore() > adjacentBox[i]->getScore())
				{
					//take the score away from origin player
					int boxScore = adjacentBox[i]->getScore();
					adjacentBox[i]->getOwner()->addScore(-boxScore);
					//reset the owner
					adjacentBox[i]->setOwner(targetBox.getOwner());
					//add score to the new owner
					targetBox.getOwner()->addScore(boxScore);
				}		
			}
		}
	}

	//change the textures....
	changeTexture(targetBox, 4);

    return true;
    
}
Esempio n. 25
0
void Indicator::set(Status status) { changeTexture(images[status]); }
Esempio n. 26
0
void OptionDialog::setBackgroundColor(const QRgb color)
{
  m_color = color;
  changeTexture(true);
}