void CombatMessageWindowWithHistory::popMessage() 
{
	int i = 0;
	TextMessage* msg = messageBuffer[ messageBuffer.size() - 1 ];
	for ( i = (int)messageBuffer.size() - 1; i > 0; i-- )
	{
		messageBuffer[ i ] = messageBuffer[ i - 1];
		if( messageBuffer[ i ] && messageBuffer[ i ]->text )
		{
			// float alpha = messageBuffer[ i ]->alpha;
			// alpha *= 0.5f;
			// messageBuffer[ i ]->alpha = alpha;
			// messageBuffer[ i ]->text->SetTransparency( (int)( 100.0f * alpha)  );
			messageBuffer[ i ]->text->Move( textXPosition, getVerticalPosition( i ) );
		}
	}

	messageBuffer[ 0 ] = NULL;

	if( msg )
	{
		delete msg->text;
		delete msg;
	}

}
void CombatMessageWindowWithHistory::pushMessage( const std::string& message )
{
	if( messageBuffer[ 0 ] != NULL ) 
		popMessage();

	messageBuffer[ 0 ] = new TextMessage;
	messageBuffer[ 0 ]->initTime = Timer::getTime();
	messageBuffer[ 0 ]->text = ogui->CreateTextLabel( win, textXPosition, getVerticalPosition( 0 ), textXSize, textHeight, message.c_str() );

	messageBuffer[ 0 ]->text->SetFont( textFont );
	messageBuffer[ 0 ]->alpha = 1.0f;

}
示例#3
0
void CChunkParticle::update(int ticks)
{
	age += ticks;
	if (age >= lifetime) {
		if (destroyAnimation) {
			CPosition p(pos.x, calculateScreenPos(pos.y, height));
			GraphicAnimation *destroyanimation = destroyAnimation->clone();
			//Wyrmgus start
//			StaticParticle *destroy = new StaticParticle(p, destroyanimation, destroyDrawLevel);
			StaticParticle *destroy = new StaticParticle(p, this->MapLayer, destroyanimation, destroyDrawLevel);
			//Wyrmgus end
			ParticleManager.add(destroy);
		}

		destroy();
		return;
	}

	const int minSmokeTicks = 150;
	const int randSmokeTicks = 50;

	if (age > nextSmokeTicks) {
		CPosition p(pos.x, calculateScreenPos(pos.y, height));
		GraphicAnimation *smokeanimation = smokeAnimation->clone();
		//Wyrmgus start
//		CSmokeParticle *smoke = new CSmokeParticle(p, smokeanimation, 0, -22.0f, smokeDrawLevel);
		CSmokeParticle *smoke = new CSmokeParticle(p, MapLayer, smokeanimation, 0, -22.0f, smokeDrawLevel);
		//Wyrmgus end
		ParticleManager.add(smoke);

		nextSmokeTicks += MyRand() % randSmokeTicks + minSmokeTicks;
	}

	debrisAnimation->update(ticks);
	if (debrisAnimation->isFinished()) {
		GraphicAnimation *debrisanimation = debrisAnimation->clone();
		delete debrisAnimation;
		debrisAnimation = debrisanimation;
	}

	float time = age / 1000.f;

	float distance = getHorizontalPosition(initialVelocity, trajectoryAngle, time);
	pos.x = initialPos.x + distance * direction.x;
	pos.y = initialPos.y + distance * direction.y;

	height = getVerticalPosition(initialVelocity, trajectoryAngle, time);
}
示例#4
0
CExtent TextStruct::getTextBox(double spaceRatio, double penWidth) const
{
   const double characterSpacing = .1; 
   const double textLeading = 1.25;

   double boxWidth = getMaxLineLength(spaceRatio,penWidth);

   int numLines = getNumLines();

   double boxHeight = m_height + ((numLines - 1) * textLeading * m_height);

   CPoint2d upperLeft(0.,0.);

   switch (getVerticalPosition())
   {
   case verticalPositionBaseline:  upperLeft.y = m_height;      break;
   case verticalPositionCenter:    upperLeft.y = boxHeight/2.;  break;
   case verticalPositionBottom:    upperLeft.y = boxHeight;     break;
   case verticalPositionTop:       upperLeft.y = 0.;            break;
   }

   switch (getHorizontalPosition())
   {
   case horizontalPositionLeft:    upperLeft.x = 0.;           break;
   case horizontalPositionCenter:  upperLeft.x = -boxWidth/2.; break;
   case horizontalPositionRight:   upperLeft.x = -boxWidth;    break;
   }

   CPoint2d lowerRight = upperLeft + CPoint2d(boxWidth,-boxHeight);

   if (m_oblique != 0)
   {
      double offset = m_height * cos(degreesToRadians(m_oblique));

      if (offset < 0.) upperLeft.x  -= offset;
      else             lowerRight.x += offset;
   }

   CExtent textBox;

   textBox.update(upperLeft);
   textBox.update(lowerRight);

   return textBox;
}