/** ** Draw missile. */ void Missile::DrawMissile(const CViewport &vp) const { Assert(this->Type); CUnit *sunit = this->SourceUnit; // FIXME: I should copy SourcePlayer for second level missiles. if (sunit && sunit->Player) { #ifdef DYNAMIC_LOAD if (!this->Type->Sprite) { LoadMissileSprite(this->Type); } #endif } const PixelPos screenPixelPos = vp.MapToScreenPixelPos(this->position); switch (this->Type->Class) { case MissileClassHit: CLabel(GetGameFont()).DrawClip(screenPixelPos.x, screenPixelPos.y, this->Damage); break; default: if (Type->G) { this->Type->DrawMissileType(this->SpriteFrame, screenPixelPos); } break; } }
/* virtual */ PixelPos COrder_Follow::Show(const CViewport &vp, const PixelPos &lastScreenPos) const { PixelPos targetPos; if (this->HasGoal()) { //Wyrmgus start if (this->GetGoal()->MapLayer != CurrentMapLayer) { return lastScreenPos; } //Wyrmgus end targetPos = vp.MapToScreenPixelPos(this->GetGoal()->GetMapPixelPosCenter()); } else { //Wyrmgus start if (this->MapLayer != CurrentMapLayer) { return lastScreenPos; } //Wyrmgus end targetPos = vp.TilePosToScreen_Center(this->goalPos); } //Wyrmgus start // Video.FillCircleClip(ColorGreen, lastScreenPos, 2); // Video.DrawLineClip(ColorGreen, lastScreenPos, targetPos); // Video.FillCircleClip(ColorGreen, targetPos, 3); if (Preference.ShowPathlines) { Video.FillCircleClip(ColorGreen, lastScreenPos, 2); Video.DrawLineClip(ColorGreen, lastScreenPos, targetPos); Video.FillCircleClip(ColorGreen, targetPos, 3); } //Wyrmgus end return targetPos; }
/* virtual */ PixelPos COrder_Board::Show(const CViewport &vp, const PixelPos &lastScreenPos) const { PixelPos targetPos; if (this->HasGoal()) { targetPos = vp.MapToScreenPixelPos(this->GetGoal()->GetMapPixelPosCenter()); } else { targetPos = vp.TilePosToScreen_Center(this->goalPos); } Video.FillCircleClip(ColorGreen, lastScreenPos, 2); Video.DrawLineClip(ColorGreen, lastScreenPos, targetPos); Video.FillCircleClip(ColorGreen, targetPos, 3); return targetPos; }
/* virtual */ PixelPos COrder_Attack::Show(const CViewport &vp, const PixelPos &lastScreenPos) const { PixelPos targetPos; if (this->HasGoal()) { targetPos = vp.MapToScreenPixelPos(this->GetGoal()->GetMapPixelPosCenter()); } else { targetPos = vp.TilePosToScreen_Center(this->goalPos); } Video.FillCircleClip(ColorRed, lastScreenPos, 2); Video.DrawLineClip(ColorRed, lastScreenPos, targetPos); Video.FillCircleClip(IsWeakTargetSelected() ? ColorBlue : ColorRed, targetPos, 3); return targetPos; }
/* virtual */ PixelPos COrder_Repair::Show(const CViewport &vp, const PixelPos &lastScreenPos) const { PixelPos targetPos; if (this->ReparableTarget != NULL) { targetPos = vp.MapToScreenPixelPos(this->ReparableTarget->GetMapPixelPosCenter()); } else { targetPos = vp.TilePosToScreen_Center(this->goalPos); } Video.FillCircleClip(ColorGreen, lastScreenPos, 2); Video.DrawLineClip(ColorGreen, lastScreenPos, targetPos); Video.FillCircleClip(ColorYellow, targetPos, 3); return targetPos; }
/** ** Show selection marker around a unit. ** ** @param unit Pointer to unit. */ void DrawUnitSelection(const CViewport &vp, const CUnit &unit) { IntColor color; // FIXME: make these colors customizable with scripts. if (Editor.Running && UnitUnderCursor == &unit && Editor.State == EditorSelecting) { color = ColorWhite; } else if (unit.Selected || unit.TeamSelected || (unit.Blink & 1)) { if (unit.Player->Index == PlayerNumNeutral) { color = ColorYellow; } else if ((unit.Selected || (unit.Blink & 1)) && (unit.Player == ThisPlayer || ThisPlayer->IsTeamed(unit))) { color = ColorGreen; } else if (ThisPlayer->IsEnemy(unit)) { color = ColorRed; } else { color = PlayerColors[GameSettings.Presets[unit.Player->Index].PlayerColor][0]; for (int i = 0; i < PlayerMax; ++i) { if (unit.TeamSelected & (1 << i)) { color = PlayerColors[GameSettings.Presets[i].PlayerColor][0]; } } } } else if (CursorBuilding && unit.Type->Building && unit.CurrentAction() != UnitActionDie && (unit.Player == ThisPlayer || ThisPlayer->IsTeamed(unit))) { // If building mark all own buildings color = ColorGray; } else { return; } const CUnitType &type = *unit.Type; const PixelPos screenPos = vp.MapToScreenPixelPos(unit.GetMapPixelPosCenter()); const int x = screenPos.x - type.BoxWidth / 2 - (type.Width - (type.Sprite ? type.Sprite->Width : 0)) / 2; const int y = screenPos.y - type.BoxHeight / 2 - (type.Height - (type.Sprite ? type.Sprite->Height : 0)) / 2; DrawSelection(color, x + type.BoxOffsetX, y + type.BoxOffsetY, x + type.BoxWidth + type.BoxOffsetX, y + type.BoxHeight + type.BoxOffsetY); }
/** ** Draw unit on map. */ void CUnit::Draw(const CViewport &vp) const { int frame; int state; int constructed; const CConstructionFrame *cframe; const CUnitType *type; if (this->Destroyed || this->Container || this->Type->Revealer) { // Revealers are not drawn return; } bool IsVisible = this->IsVisible(*ThisPlayer); // Those should have been filtered. Check doesn't make sense with ReplayRevealMap Assert(ReplayRevealMap || this->Type->VisibleUnderFog || IsVisible); int player = this->RescuedFrom ? this->RescuedFrom->Index : this->Player->Index; int action = this->CurrentAction(); PixelPos screenPos; if (ReplayRevealMap || IsVisible) { screenPos = vp.MapToScreenPixelPos(this->GetMapPixelPosTopLeft()); type = this->Type; frame = this->Frame; state = (action == UnitActionBuilt) | ((action == UnitActionUpgradeTo) << 1); constructed = this->Constructed; // Reset Type to the type being upgraded to if (action == UnitActionUpgradeTo) { const COrder_UpgradeTo &order = *static_cast<COrder_UpgradeTo *>(this->CurrentOrder()); type = &order.GetUnitType(); } if (this->CurrentAction() == UnitActionBuilt) { COrder_Built &order = *static_cast<COrder_Built *>(this->CurrentOrder()); cframe = &order.GetFrame(); } else { cframe = NULL; } } else { screenPos = vp.TilePosToScreen_TopLeft(this->Seen.tilePos); screenPos.x += this->Seen.IX; screenPos.y += this->Seen.IY; frame = this->Seen.Frame; type = this->Seen.Type; constructed = this->Seen.Constructed; state = this->Seen.State; cframe = this->Seen.CFrame; } #ifdef DYNAMIC_LOAD if (!type->Sprite) { LoadUnitTypeSprite(type); } #endif if (!IsVisible && frame == UnitNotSeen) { DebugPrint("FIXME: Something is wrong, unit %d not seen but drawn time %lu?.\n" _C_ UnitNumber(*this) _C_ GameCycle); return; } if (state == 1 && constructed && cframe) { DrawConstructionShadow(*type, cframe, frame, screenPos); } else { if (action != UnitActionDie) { DrawShadow(*type, frame, screenPos); } } // // Show that the unit is selected // DrawUnitSelection(vp, *this); // // Adjust sprite for Harvesters. // CPlayerColorGraphic *sprite = type->Sprite; if (type->Harvester && this->CurrentResource) { ResourceInfo *resinfo = type->ResInfo[this->CurrentResource]; if (this->ResourcesHeld) { if (resinfo->SpriteWhenLoaded) { sprite = resinfo->SpriteWhenLoaded; } } else { if (resinfo->SpriteWhenEmpty) { sprite = resinfo->SpriteWhenEmpty; } } } // // Now draw! // Buildings under construction/upgrade/ready. // if (state == 1) { if (constructed && cframe) { const PixelPos pos(screenPos + (type->GetPixelSize()) / 2); DrawConstruction(GameSettings.Presets[player].PlayerColor, cframe, *type, frame, pos); } else { DrawUnitType(*type, sprite, GameSettings.Presets[player].PlayerColor, frame, screenPos); } // // Draw the future unit type, if upgrading to it. // } else { DrawUnitType(*type, sprite, GameSettings.Presets[player].PlayerColor, frame, screenPos); } // Unit's extras not fully supported.. need to be decorations themselves. DrawInformations(*this, *type, screenPos); }