コード例 #1
0
/**
**  Draw decoration (invis, for the unit.)
**
**  @param unit  Pointer to the unit.
**  @param type  Type of the unit.
**  @param x     Screen X position of the unit.
**  @param y     Screen Y position of the unit.
*/
static void DrawDecoration(const CUnit *unit, const CUnitType *type, int x, int y)
{
#ifdef REFS_DEBUG
	//
	// Show the number of references.
	//
	VideoDrawNumberClip(x + 1, y + 1, GameFont, unit->Refs);
#endif

	UpdateUnitVariables(unit);
	// Now show decoration for each variable.
	for (std::vector<CDecoVar *>::const_iterator i = UnitTypeVar.DecoVar.begin();
		i < UnitTypeVar.DecoVar.end(); ++i) {
		int value;
		int max;

		value = unit->Variable[(*i)->Index].Value;
		max = unit->Variable[(*i)->Index].Max;
		Assert(value <= max);

		if (!((value == 0 && !(*i)->ShowWhenNull) || (value == max && !(*i)->ShowWhenMax) ||
				((*i)->HideHalf && value != 0 && value != max) ||
				(!(*i)->ShowIfNotEnable && !unit->Variable[(*i)->Index].Enable) ||
				((*i)->ShowOnlySelected && !unit->Selected) ||
				(unit->Player->Type == PlayerNeutral && (*i)->HideNeutral) ||
				(ThisPlayer->IsEnemy(unit) && !(*i)->ShowOpponent) ||
				(ThisPlayer->IsAllied(unit) && (unit->Player != ThisPlayer) && (*i)->HideAllied) ||
				max == 0)) {
			(*i)->Draw(
				x + (*i)->OffsetX + (*i)->OffsetXPercent * unit->Type->TileWidth * TileSizeX / 100,
				y + (*i)->OffsetY + (*i)->OffsetYPercent * unit->Type->TileHeight * TileSizeY / 100,
				unit);
		}
	}
	//
	// Draw group number
	//
	if (unit->Selected && unit->GroupId != 0) {
		char buf[2];
		int num;
		int f;

		for (num = 0; !(unit->GroupId & (1 << num)); ++num) {
			;
		}
		buf[0] = num + '0';
		buf[1] = '\0';
		f = GameFont->Width(buf);
		x += (type->TileWidth * TileSizeX + type->BoxWidth) / 2 - f;
		f = GameFont->Height();
		y += (type->TileHeight * TileSizeY + type->BoxHeight) / 2 - f;
		VideoDrawNumberClip(x, y, GameFont, num);
	}
}
コード例 #2
0
/**
**  Print variable values (and max....).
**
**  @param x       X screen pixel position
**  @param y       Y screen pixel position
**  @param unit    Unit pointer
**  @todo fix font/color configuration.
*/
void CDecoVarText::Draw(int x, int y, const CUnit *unit) const
{
	if (this->IsCenteredInX) {
		x -= 2; // GameFont->Width(buf) / 2, with buf = str(Value)
	}
	if (this->IsCenteredInY) {
		y -= this->Font->Height() / 2;
	}
	VideoDrawNumberClip(x, y, this->Font, unit->Variable[this->Index].Value);
}
コード例 #3
0
/**
**  Draw decoration (invis, for the unit.)
**
**  @param unit  Pointer to the unit.
**  @param type  Type of the unit.
**  @param x     Screen X position of the unit.
**  @param y     Screen Y position of the unit.
*/
static void DrawDecoration(const CUnit &unit, const CUnitType *type, int x, int y)
{
#ifdef REFS_DEBUG
	//
	// Show the number of references.
	//
	VideoDrawNumberClip(x + 1, y + 1, GameFont, unit.Refs);
#endif

	UpdateUnitVariables(unit);
	// Now show decoration for each variable.
	for (std::vector<CDecoVar *>::const_iterator i = UnitTypeVar.DecoVar.begin();
			i < UnitTypeVar.DecoVar.end(); ++i) {
		int value;
		int max;
		const CDecoVar *var = (*i);
		value = unit.Variable[var->Index].Value;
		max = unit.Variable[var->Index].Max;
		Assert(value <= max);

		if (!((value == 0 && !var->ShowWhenNull) || (value == max && !var->ShowWhenMax) ||
				(var->HideHalf && value != 0 && value != max) ||
				(!var->ShowIfNotEnable && !unit.Variable[var->Index].Enable) ||
				(var->ShowOnlySelected && !unit.Selected) ||
				(unit.Player->Type == PlayerNeutral && var->HideNeutral) ||
				(ThisPlayer->IsEnemy(unit) && !var->ShowOpponent) ||
				(ThisPlayer->IsAllied(unit) && (unit.Player != ThisPlayer) && var->HideAllied) ||
				max == 0)) {
			var->Draw(
				x + var->OffsetX + var->OffsetXPercent * unit.Type->TileWidth * TileSizeX / 100,
				y + var->OffsetY + var->OffsetYPercent * unit.Type->TileHeight * TileSizeY / 100,
				type, unit.Variable[var->Index]);
		}
	}

	//
	// Draw group number
	//
	if (unit.Selected && unit.GroupId != 0
#ifndef DEBUG
		&& unit.Player == ThisPlayer
#endif
		) {
		int groupId = 0;
		for (groupId = 0; !(unit.GroupId & (1 << groupId)); ++groupId)
			;
		int width = GameFont->Width(groupId);
		x += (unit.Type->TileWidth * TileSizeX + unit.Type->BoxWidth) / 2 - width;
		width = GameFont->Height();
		y += (unit.Type->TileHeight * TileSizeY + unit.Type->BoxHeight) / 2 - width;
		CLabel(GameFont).DrawClip(x, y, groupId);
	}
}
コード例 #4
0
ファイル: missile.cpp プロジェクト: OneSleepyDev/boswars_osd
/**
**  Draw missile.
*/
void Missile::DrawMissile() const
{
	int x;
	int y;
	const CViewport *vp;

	Assert(this->Type);
	Assert(CurrentViewport);

	vp = CurrentViewport;
	x = this->X - vp->MapX * TileSizeX + vp->X - vp->OffsetX;
	y = this->Y - vp->MapY * TileSizeY + vp->Y - vp->OffsetY;
	switch (this->Type->Class) {
		case MissileClassHit:
			VideoDrawNumberClip(x, y, GameFont, this->Damage);
			break;
		default:
			this->Type->DrawMissileType(this->SpriteFrame, x, y);
			break;
	}
}
コード例 #5
0
ファイル: unit_draw.c プロジェクト: hhirsch/open_conflict
/**
**	Draw decoration (invis, for the unit.)
**
**	@param unit	Pointer to the unit.
**	@param type	Type of the unit.
**	@param x	Screen X position of the unit.
**	@param y	Screen Y position of the unit.
*/
local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
{
    int f;
    int color;
    int w;
    int x1;
    int y1;
    const UnitStats* stats;

#ifdef REFS_DEBUG
    //
    //	Show the number of references.
    //
    VideoDrawNumberClip(x+1,y+1,GameFont,unit->Refs);
#endif

    //
    //	Only for selected units?
    //
    if( ShowEnergySelectedOnly && !unit->Selected ) {
	return;
    }

    //
    //	Health bar on left side of unit.
    //
    stats=unit->Stats;
    if( (!type->Critter || unit->Player->Type!=PlayerRaceNeutral)
		&& ShowHealthBar ) {
	if( stats->HitPoints
		&& !(ShowNoFull && unit->HP==stats->HitPoints) ) {
	    f=(100*unit->HP)/stats->HitPoints;
	    if( f>75) {
		color=ColorDarkGreen;
	    } else if( f>50 ) {
		color=ColorYellow;
	    } else if( f>25 ) {
		color=ColorOrange;
	    } else {
		color=ColorRed;
	    }
	    if ( ShowHealthHorizontal )  {
		//
		//	Draw the black rectangle in full size?
		//
		if( ShowHealthBackgroundLong ) {
#if defined(DEBUG)
		    // Johns: I want to see fast moving.
		    //VideoFillRectangleClip(unit->Data.Move.Fast
		    // Johns: I want to see the AI active flag
		    VideoFillRectangleClip(unit->Active
			    ? ColorBlack : ColorWhite
#else
		    VideoFillRectangleClip(ColorBlack
#endif
			,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
			,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
				+type->BoxHeight+1
			,type->BoxHeight+1
			,5);
		} else {
#if defined(DEBUG)
		    // Johns: I want to see fast moving.
		    VideoFillRectangleClip(unit->Data.Move.Fast
			    ? ColorBlack : ColorWhite
#else
		    VideoFillRectangleClip(ColorBlack
#endif
			,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)
			,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
				+type->BoxHeight+1
			,((f*type->BoxHeight)/100)+1
			,5);
		}
              w = (f*type->BoxHeight)/100-1;
              if ( w > 0 ) // Prevents -1 turning into unsigned int
		VideoFillRectangleClip(color
		    ,x+((type->TileWidth*TileSizeX-type->BoxWidth)/2)+1
		    ,(y+(type->TileHeight*TileSizeY-type->BoxHeight)/2)
			    +type->BoxHeight+2
		    ,w
		    ,3);
	    }  else  {