Exemple #1
0
void C4SolidMask::Draw(C4FacetEx &cgo) {
  // only if put
  if (!MaskPut) return;
  // set topface facet
  C4Facet fct;
  fct.Set(pForObject->GetGraphics()->GetBitmap(), pForObject->SolidMask.x,
          pForObject->SolidMask.y, pForObject->SolidMask.Wdt,
          pForObject->SolidMask.Hgt);
  // draw it
  if (MaskPutRotation)
    fct.DrawXR(cgo.Surface, pForObject->x + pForObject->Shape.x + cgo.X -
                                cgo.TargetX + pForObject->SolidMask.tx,
               pForObject->y + pForObject->Shape.y + cgo.Y - cgo.TargetY +
                   pForObject->SolidMask.ty,
               fct.Wdt, fct.Hgt, 0, 0, MaskPutRotation);
  else
    fct.DrawX(cgo.Surface, pForObject->x + pForObject->Shape.x + cgo.X -
                               cgo.TargetX + pForObject->SolidMask.tx,
              pForObject->y + pForObject->Shape.y + cgo.Y - cgo.TargetY +
                  pForObject->SolidMask.ty,
              fct.Wdt, fct.Hgt, 0, 0);
}
Exemple #2
0
bool C4RankSystem::DrawRankSymbol(C4FacetExSurface *fctSymbol, int32_t iRank, C4FacetEx *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff, C4Facet *cgoDrawDirect)
	{
	// safety
	if (iRank<0) iRank = 0;
	// symbol by rank
	int32_t iMaxRankSym,Q;
	if (pfctRankSymbols->GetPhaseNum(iMaxRankSym, Q))
		{
		if (!iMaxRankSym) iMaxRankSym=1;
		int32_t iBaseRank=iRank%iRankSymbolCount;
		if (iRank/iRankSymbolCount)
			{
			// extended rank: draw
			// extension star defaults to captain star; but use extended symbols if they are in the gfx
			C4Facet fctExtended = (const C4Facet &) Game.GraphicsResource.fctCaptain;
			if (iMaxRankSym > iRankSymbolCount)
				{
				int32_t iExtended = iRank / iRankSymbolCount - 1 + iRankSymbolCount;
				if (iExtended >= iMaxRankSym)
					{
					// max rank exceeded
					iExtended = iMaxRankSym - 1;
					iBaseRank = iRankSymbolCount - 1;
					}
				fctExtended = (const C4Facet &) pfctRankSymbols->GetPhase(iExtended);
				}
			int32_t iSize = pfctRankSymbols->Wdt;
			if (!cgoDrawDirect)
				{
				fctSymbol->Create(iSize,iSize);
				pfctRankSymbols->DrawX(fctSymbol->Surface, 0,0,iSize,iSize,iBaseRank);
				fctExtended.DrawX(fctSymbol->Surface, 0,0,iSize*2/3,iSize*2/3);
				}
			else
				{
				pfctRankSymbols->Draw(cgoDrawDirect->Surface,cgoDrawDirect->X+iXOff,cgoDrawDirect->Y,iBaseRank);
				fctExtended.Draw(cgoDrawDirect->Surface, cgoDrawDirect->X+iXOff-4,cgoDrawDirect->Y-3);
				}
			}
		else
			{
			// regular rank: copy facet
			if (cgoDrawDirect)
				{
				pfctRankSymbols->Draw(cgoDrawDirect->Surface, cgoDrawDirect->X+iXOff,cgoDrawDirect->Y,iBaseRank);
				}
			else if (fOwnSurface)
				{
				int32_t iSize = pfctRankSymbols->Wdt;
				fctSymbol->Create(iSize,iSize);
				pfctRankSymbols->DrawX(fctSymbol->Surface, 0,0,iSize,iSize,iBaseRank);
				}
			else
				{
				fctSymbol->Set(pfctRankSymbols->GetPhase(iBaseRank));
				}
			}
		return true;
		}
	return false;
	}