示例#1
0
void TextWidget::recalculateText()
{
	// perform text initialization.
	loadTextFont();

	myText.setColor(isEnabled() ? getTextColor() : fadeColor(getTextColor(), 0.6f));

	sf::FloatRect boundingBox = getTextMaxBoundingBox();
	sf::Vector2f pos(boundingBox.left, boundingBox.top);

	myText.setMaxSize(sf::Vector2f(boundingBox.width, boundingBox.height));
	sf::Vector2f textSize(getTextSize());

	pos.x += (boundingBox.width - textSize.x) * getTextPreciseAlignment().x;
	pos.y += (boundingBox.height - textSize.y) * getTextPreciseAlignment().y;

	/*
	switch (convertAlignmentHorizontal(getTextAlignment()))
	{
	case AlignLeft:
	default:
		break;

	case AlignCenter:
		pos.x += (boundingBox.width - textSize.x) / 2.f;
		break;

	case AlignRight:
		pos.x += boundingBox.width - textSize.x;
		break;
	}

	switch (convertAlignmentVertical(getTextAlignment()))
	{
	case AlignTop:
	default:
		break;

	case AlignCenter:
		pos.y += (boundingBox.height - textSize.y) / 2.f;
		break;

	case AlignBottom:
		pos.y += boundingBox.height - textSize.y;
		break;
	}
	*/

	if (isTextPixelPerfect())
		pos = sf::Vector2f(sf::Vector2i(pos + sf::Vector2f(0.5f, 0.5f)));

	if (pos != myText.getPosition())
	{
		myText.setPosition(pos);
		myText.updateMinor();
	}
}
示例#2
0
void Palette::update() {
	debug(2, "Palette::update() _status = %d", _status);
	if (_status == 1) {
		if (_palCounter > 1) {
			for (int i = 0; i < 256; i++)
				fadeColor(_palette + i * 4, _fadeToR, _fadeToG, _fadeToB);
			_vm->_screen->testPalette(_palette);
			_palCounter--;
		} else {
			memset(_palette, 0, 1024);
			_status = 0;
		}
	} else if (_status == 2) {
		if (_palCounter > 1) {
			for (int i = 0; i < 256; i++)
				fadeColor(_palette + i * 4, _basePalette[i * 4 + 0], _basePalette[i * 4 + 1], _basePalette[i * 4 + 2]);
			_vm->_screen->testPalette(_palette);
			_palCounter--;
		} else {
			memcpy(_palette, _basePalette, 256 * 4);
			_status = 0;
		}
	}
}
示例#3
0
void Ball::setFadeColor(unsigned char color){
	if(color==1)
		fadeColor(FALSE,TRUE,TRUE);
	if(color==2)
		fadeColor(FALSE,FALSE,TRUE);
	if(color==3)
		fadeColor(FALSE, TRUE, FALSE);
	if(color==4)
		fadeColor(TRUE, FALSE, FALSE);
	if(color==5)
		fadeColor(TRUE,FALSE,TRUE);
	if(color==6)
		fadeColor(TRUE,TRUE,FALSE);
	if(color==7)
		fadeColor(TRUE,TRUE,TRUE);
}
示例#4
0
bool PalAnim::fadeStep(int16 oper) {
	bool stop = true;
	byte newRed;
	byte newGreen;
	byte newBlue;

	if (_vm->_global->_colorCount != 256)
		error("PalAnim::fadeStep(): Only 256 color mode is supported");

	if (oper == 0) {
		if (_vm->_global->_setAllPalette) {
			if (_vm->_global->_inVM != 0)
				error("PalAnim::fadeStep(): _vm->_global->_inVM != 0 not supported");

			for (int i = 0; i < 256; i++) {
				newRed = fadeColor(_vm->_global->_redPalette[i], _toFadeRed[i]);
				newGreen = fadeColor(_vm->_global->_greenPalette[i], _toFadeGreen[i]);
				newBlue = fadeColor(_vm->_global->_bluePalette[i], _toFadeBlue[i]);

				if ((_vm->_global->_redPalette[i] != newRed) ||
				    (_vm->_global->_greenPalette[i] != newGreen) ||
				    (_vm->_global->_bluePalette[i] != newBlue)) {

					_vm->_video->setPalElem(i, newRed, newGreen, newBlue, 0, 0x13);

					_vm->_global->_redPalette[i] = newRed;
					_vm->_global->_greenPalette[i] = newGreen;
					_vm->_global->_bluePalette[i] = newBlue;
					stop = false;
				}
			}
		} else {
			for (int i = 0; i < 16; i++) {

				_vm->_video->setPalElem(i,
						fadeColor(_vm->_global->_redPalette[i], _toFadeRed[i]),
						fadeColor(_vm->_global->_greenPalette[i], _toFadeGreen[i]),
						fadeColor(_vm->_global->_bluePalette[i], _toFadeBlue[i]),
						-1, _vm->_global->_videoMode);

				if ((_vm->_global->_redPalette[i] != _toFadeRed[i]) ||
				    (_vm->_global->_greenPalette[i] != _toFadeGreen[i]) ||
				    (_vm->_global->_bluePalette[i] != _toFadeBlue[i]))
					stop = false;
			}
		}
	} else if ((oper > 0) && (oper < 4))
		stop = fadeStepColor(oper - 1);

	return stop;
}
示例#5
0
bool PalAnim::fadeStepColor(int color) {
	bool stop = true;
	char colors[3];

	for (int i = 0; i < 16; i++) {
		colors[0] = _palArray[0][i];
		colors[1] = _palArray[1][i];
		colors[2] = _palArray[2][i];
		colors[color] = fadeColor(_palArray[color][i], _fadeArray[color][i]);

		_vm->_video->setPalElem(i, colors[0], colors[1], colors[2],
				-1, _vm->_global->_videoMode);

		if (_palArray[color][i] != _fadeArray[color][i])
			stop = false;
	}

	return stop;
}
void RGBElement::update()
{
    /*
     * WAIT FOR NEXT WAIT TIME /
     */
    /*
     * IF COLOR CHANGE PRINT STATUS
     */
    if(!isReady())
    {
        if(m_fade)
        {
            fadeColor();
        }
        else
        {
            switchColor();
        }
        writeRGB();
    }
    if(m_sync||(m_play && (millis()> m_nextWait)))
    {
        m_nextWait = millis()+ (m_wTime * 1000);
        stateMaschine();
        if(m_state > 3)
        {
            m_sync = false;
        }
    }
    else if(!m_play)
    {
        /*
         * SAVE WAIT TIME STATE
         *  ADD DURATION QUICKFIX
         */
        if(m_nextWait > millis())
        {
            int diff = m_nextWait - millis();
            m_nextWait += diff;
        }
    }
}