void Button::deactivate() { Component::deactivate(); if (isToggle_) { if (isSelected()) changeTexture(Selected); else changeTexture(Normal); } }
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); } }
void Button::select() { Widget::select(); changeTexture(Type::Selected); soundPlayer.play(SoundEffects::ID::ButtonHover); }
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); }
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))); }
Button::Button(State::Context context) : callback_(), sprite_(context.textures->resource(TextureId::Buttons)), text_("", context.fonts->resource(FontId::Regular)), isToggle_(false) { changeTexture(Normal); centerOrigin(sprite_); }
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); }
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); }
/* 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(); } } }
void Button::activate() { Component::activate(); if (isToggle_) changeTexture(Pressed); if (callback_) callback_(); if (!isToggle_) deactivate(); }
void BrickBonus::animationDestroy() { if (_type == EWALL) { _sprite->stopActionByTag(BLINK_TAG); _sprite->setColor(_oldColor); changeTexture(EBACKGROUND); _type = EBONUS; } if (!createBonus()) { animateDestroyBonus(); } }
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); }
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(); }
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(); }
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); }
void Button::deactivate() { Widget::deactivate(); changeTexture(Type::Selected); }
void Button::deselect() { Component::deselect(); changeTexture(Normal); }
void Button::select() { Component::select(); changeTexture(Selected); }
void Button::setTexture(const sf::Texture &texture) { sprite.setTexture(texture); changeTexture(Type::Normal); centerText(); }
void Button::deselect() { Widget::deselect(); changeTexture(Type::Normal); }
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; }
void Indicator::set(Status status) { changeTexture(images[status]); }
void OptionDialog::setBackgroundColor(const QRgb color) { m_color = color; changeTexture(true); }