Example #1
0
bool C4FacetExSurface::EnsureOwnSurface() {
  // is it a link?
  if (Surface != &Face) {
    // then recreate in same size
    C4Facet fctOld = *this;
    if (!Create(fctOld.Wdt, fctOld.Hgt)) return false;
    fctOld.Draw(*this);
  }
  return true;
}
	bool Picture::EnsureOwnSurface()
	{
		// no surface?
		if (!Facet.Surface) return false;
		// equals face already?
		if (Facet.Surface == &Facet.GetFace()) return true;
		// then create as a copy
		C4Facet cgo = Facet;
		if (!Facet.Create(cgo.Wdt, cgo.Hgt)) return false;
		cgo.Draw(Facet);
		return true;
	}
Example #3
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;
	}