OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GraphicsOverlay Class Reference

#include <C4DefGraphics.h>

Collaboration diagram for C4GraphicsOverlay:
[legend]

Public Types

enum  Mode {
  MODE_None =0, MODE_Base =1, MODE_Action =2, MODE_Picture =3,
  MODE_IngamePicture =4, MODE_Object =5, MODE_ExtraGraphics =6, MODE_Rank =7,
  MODE_ObjectPicture =8
}
 

Public Member Functions

 C4GraphicsOverlay ()
 
 ~C4GraphicsOverlay ()
 
void CompileFunc (StdCompiler *pComp)
 
void DenumeratePointers ()
 
void SetAsBase (C4DefGraphics *pBaseGfx, DWORD dwBMode)
 
void SetAsAction (C4DefGraphics *pBaseGfx, const char *szAction, DWORD dwBMode)
 
void SetAsPicture (C4DefGraphics *pBaseGfx, DWORD dwBMode)
 
void SetAsIngamePicture (C4DefGraphics *pBaseGfx, DWORD dwBMode)
 
void SetAsObject (C4Object *pOverlayObj, DWORD dwBMode)
 
void SetAsObjectPicture (C4Object *pOverlayObj, DWORD dwBMode)
 
void SetAsExtraGraphics (C4DefGraphics *pGfx, DWORD dwBMode)
 
void SetAsRank (DWORD dwBMode, C4Object *rank_obj)
 
bool IsValid (const C4Object *pForObj) const
 
C4DrawTransformGetTransform ()
 
C4ObjectGetOverlayObject () const
 
int32_t GetID () const
 
void SetID (int32_t aID)
 
void SetPhase (int32_t iToPhase)
 
C4GraphicsOverlayGetNext () const
 
void SetNext (C4GraphicsOverlay *paNext)
 
bool IsPicture ()
 
C4DefGraphicsGetGfx () const
 
void Draw (C4TargetFacet &cgo, C4Object *pForObj, int32_t iByPlayer)
 
void DrawPicture (C4Facet &cgo, C4Object *pForObj, C4DrawTransform *trans)
 
void DrawRankSymbol (C4Facet &cgo, C4Object *rank_obj)
 
bool operator== (const C4GraphicsOverlay &rCmp) const
 
uint32_t GetClrModulation () const
 
void SetClrModulation (uint32_t dwToMod)
 
uint32_t GetBlitMode () const
 
void SetBlitMode (uint32_t dwToMode)
 

Protected Member Functions

void UpdateFacet ()
 
void Set (Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)
 

Protected Attributes

Mode eMode
 
C4DefGraphicspSourceGfx
 
char Action [C4MaxName+1]
 
C4TargetFacet fctBlit
 
StdMeshInstancepMeshInstance
 
uint32_t dwBlitMode
 
uint32_t dwClrModulation
 
C4ObjectPtr OverlayObj
 
C4DrawTransform Transform
 
int32_t iPhase
 
bool fZoomToShape
 
int32_t iID
 
C4GraphicsOverlaypNext
 

Friends

class C4DefGraphicsPtrBackupEntry
 
class C4DefGraphicsPtrBackup
 

Detailed Description

Definition at line 164 of file C4DefGraphics.h.

Member Enumeration Documentation

Enumerator
MODE_None 
MODE_Base 
MODE_Action 
MODE_Picture 
MODE_IngamePicture 
MODE_Object 
MODE_ExtraGraphics 
MODE_Rank 
MODE_ObjectPicture 

Definition at line 169 of file C4DefGraphics.h.

170  {
171  MODE_None=0,
172  MODE_Base=1, // display base facet
173  MODE_Action=2, // display action facet specified in Action
174  MODE_Picture=3, // overlay picture to this picture only
175  MODE_IngamePicture=4, // draw picture of source def
176  MODE_Object=5, // draw another object gfx
177  MODE_ExtraGraphics=6, // draw like this were a ClrByOwner-surface
178  MODE_Rank=7, // draw rank symbol
179  MODE_ObjectPicture=8 // draw the picture of source object
180  };

Constructor & Destructor Documentation

C4GraphicsOverlay::C4GraphicsOverlay ( )
inline

Definition at line 203 of file C4DefGraphics.h.

203  : eMode(MODE_None), pSourceGfx(nullptr), fctBlit(), pMeshInstance(nullptr), dwBlitMode(0), dwClrModulation(0xffffff),
204  OverlayObj(nullptr), Transform(+1),
205  iPhase(0), fZoomToShape(false), iID(0), pNext(nullptr) { *Action=0; } // std ctor
C4GraphicsOverlay * pNext
char Action[C4MaxName+1]
StdMeshInstance * pMeshInstance
uint32_t dwClrModulation
C4TargetFacet fctBlit
C4DrawTransform Transform
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx
C4GraphicsOverlay::~C4GraphicsOverlay ( )

Definition at line 699 of file C4DefGraphics.cpp.

References pMeshInstance, and pNext.

700 {
701  // Free mesh instance
702  delete pMeshInstance; pMeshInstance = nullptr;
703  // free any additional overlays
704  C4GraphicsOverlay *pNextOther = pNext, *pOther;
705  while ((pOther = pNextOther))
706  {
707  pNextOther = pOther->pNext;
708  pOther->pNext = nullptr;
709  delete pOther;
710  }
711 }
C4GraphicsOverlay * pNext
StdMeshInstance * pMeshInstance

Member Function Documentation

void C4GraphicsOverlay::CompileFunc ( StdCompiler pComp)

Definition at line 846 of file C4DefGraphics.cpp.

References Action, dwBlitMode, dwClrModulation, eMode, iID, iPhase, StdCompiler::isDeserializer(), mkDefaultAdapt(), mkIntAdapt(), mkStringAdaptMIE, OverlayObj, pSourceGfx, StdCompiler::SEP_END, StdCompiler::SEP_START, StdCompiler::Separator(), Transform, UpdateFacet(), and StdCompiler::Value().

847 {
848  // read ID
849  pComp->Value(iID); pComp->Separator();
850  // read def-graphics
852  pComp->Separator();
853  // read mode
854  pComp->Value(mkIntAdapt(eMode)); pComp->Separator();
855  // read action (identifier)
856  pComp->Value(mkStringAdaptMIE(Action)); pComp->Separator();
857  // read blit mode
858  pComp->Value(dwBlitMode); pComp->Separator();
859  // read phase
860  pComp->Value(iPhase); pComp->Separator();
861  // read transform
863  pComp->Value(Transform);
865  // read color-modulation
866  if (pComp->Separator())
868  else
869  // default
870  if (pComp->isDeserializer()) dwClrModulation = 0xffffff;
871  // read overlay target object
872  if (pComp->Separator())
873  pComp->Value(OverlayObj);
874  else
875  // default
876  if (pComp->isDeserializer()) OverlayObj = nullptr;
877  // update used facet according to read data
878  if (pComp->isDeserializer()) UpdateFacet();
879 }
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:129
char Action[C4MaxName+1]
uint32_t dwClrModulation
void Value(const T &rStruct)
Definition: StdCompiler.h:171
virtual bool isDeserializer()
Definition: StdCompiler.h:63
C4DrawTransform Transform
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:65
StdIntAdapt< T > mkIntAdapt(T &rValue)
Definition: StdAdaptors.h:230
#define mkStringAdaptMIE(szString)
Definition: StdAdaptors.h:193

Here is the call graph for this function:

void C4GraphicsOverlay::DenumeratePointers ( )

Definition at line 881 of file C4DefGraphics.cpp.

References C4ObjectPtr::DenumeratePointers(), and OverlayObj.

882 {
884 }
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:46
C4ObjectPtr OverlayObj

Here is the call graph for this function:

void C4GraphicsOverlay::Draw ( C4TargetFacet cgo,
C4Object pForObj,
int32_t  iByPlayer 
)

Definition at line 886 of file C4DefGraphics.cpp.

References C4Draw::ActivateBlitModulation(), C4GFXBLIT_PARENT, C4ValueToMatrix(), C4Object::Color, C4Draw::DeactivateBlitModulation(), C4DefGraphics::Draw(), C4Object::Draw(), C4Object::DrawPicture(), DrawRankSymbol(), C4Facet::DrawT(), C4Object::DrawTopFace(), dwBlitMode, dwClrModulation, eMode, fctBlit, fZoomToShape, C4Object::GetDrawPosition(), C4Object::GetGraphics(), C4PropList::GetProperty(), C4DrawTransform::GetXOffset(), C4DrawTransform::GetYOffset(), C4Rect::Hgt, C4Facet::Hgt, iPhase, IsPicture(), MODE_ExtraGraphics, MODE_IngamePicture, MODE_ObjectPicture, MODE_Picture, MODE_Rank, C4Object::ODM_BaseOnly, C4Object::ODM_Overlay, OverlayObj, P_MeshTransformation, C4DefGraphics::pDef, pDraw, C4Object::pDrawTransform, pMeshInstance, pSourceGfx, C4Draw::RenderMesh(), C4Draw::ResetBlitMode(), C4BltTransform::ScaleAt(), C4Facet::Set(), C4TargetFacet::Set(), C4Draw::SetBlitMode(), C4Surface::SetClr(), StdMeshInstance::SetFaceOrderingForClrModulation(), C4Object::SetGraphics(), C4Draw::SetMeshTransform(), C4Def::Shape, C4Object::Shape, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, Transform, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, C4Facet::Y, and C4TargetFacet::Zoom.

887 {
888  assert(!IsPicture());
889  // note: Also called with pForObj==nullptr for editor placement preview
890  // get target pos
891  float offX, offY;
892  float newzoom;
893  if (pForObj)
894  {
895  pForObj->GetDrawPosition(cgo, offX, offY, newzoom);
896  }
897  else
898  {
899  // offset in editor mode preview
900  offX = cgo.X;
901  offY = cgo.Y;
902  newzoom = cgo.Zoom;
903  }
904  ZoomDataStackItem zdsi(newzoom);
905 
906  // special blit mode
908  {
909  assert(pForObj);
910  (OverlayObj ? static_cast<C4Object*>(OverlayObj) : pForObj)->PrepareDrawing();
911  }
912  else
913  {
916 
917  if (pMeshInstance)
919  }
920  if (eMode == MODE_Rank)
921  {
922  assert(pForObj);
923  C4TargetFacet ccgo;
924  ccgo.Set(cgo.Surface, offX+pForObj->Shape.x,offY+pForObj->Shape.y,pForObj->Shape.Wdt,pForObj->Shape.Hgt, cgo.TargetX, cgo.TargetY);
925  DrawRankSymbol(ccgo, OverlayObj);
926  }
927  // drawing specific object?
928  else if (OverlayObj)
929  {
930  assert(pForObj);
931  // TODO: Shouldn't have called PrepareDrawing/set ClrModulation here, since
932  // OverlayObj drawing will do it on its own.
933  if (eMode == MODE_ObjectPicture)
934  {
935  C4Facet fctTarget;
936  fctTarget.Set(cgo.Surface, offX+pForObj->Shape.x, offY+pForObj->Shape.y, pForObj->Shape.Wdt, pForObj->Shape.Hgt);
937 
938  OverlayObj->DrawPicture(fctTarget, false, &C4DrawTransform(Transform, fctTarget.X+float(fctTarget.Wdt)/2, fctTarget.Y+float(fctTarget.Hgt)/2));
939  }
940  else
941  {
942  // Draw specified object at target pos of this object; offset by transform.
943  OverlayObj->Draw(cgo, iByPlayer, C4Object::ODM_Overlay, offX + Transform.GetXOffset(), offY + Transform.GetYOffset());
945  }
946  }
947  else if (eMode == MODE_ExtraGraphics)
948  {
949  assert(pForObj);
950  // draw self with specified gfx
951  if (pSourceGfx)
952  {
953  C4DefGraphics *pPrevGfx = pForObj->GetGraphics();
954  C4DrawTransform *pPrevTrf = pForObj->pDrawTransform;
955  C4DrawTransform trf;
956  if (pPrevTrf)
957  {
958  trf = *pPrevTrf;
959  trf *= Transform;
960  }
961  else
962  {
963  trf = Transform;
964  }
965  pForObj->SetGraphics(pSourceGfx, true);
966  pForObj->pDrawTransform = &trf;
967  pForObj->Draw(cgo, iByPlayer, C4Object::ODM_BaseOnly);
968  pForObj->DrawTopFace(cgo, iByPlayer, C4Object::ODM_BaseOnly);
969  pForObj->SetGraphics(pPrevGfx, true);
970  pForObj->pDrawTransform = pPrevTrf;
971  }
972  }
973  else if(eMode == MODE_Picture || eMode == MODE_IngamePicture)
974  {
975  assert(pForObj);
976  float twdt, thgt;
977  if (fZoomToShape)
978  {
979  twdt = pForObj->Shape.Wdt;
980  thgt = pForObj->Shape.Hgt;
981  }
982  else
983  {
984  twdt = pSourceGfx->pDef->Shape.Wdt;
985  thgt = pSourceGfx->pDef->Shape.Hgt;
986  }
987 
988  C4TargetFacet ccgo;
989  ccgo.Set(cgo.Surface, offX-twdt/2, offY-thgt/2, twdt, thgt, cgo.TargetX, cgo.TargetY);
990  C4DrawTransform trf(Transform, offX, offY);
991 
992  // Don't set pForObj because we don't draw the picture of pForObj, but the picture of another definition on top of pForObj:
993  pSourceGfx->Draw(ccgo, pForObj->Color, nullptr, iPhase, 0, &trf);
994  }
995  else
996  {
997  // no object specified: Draw from fctBlit
998  // update by object color
999  if (fctBlit.Surface && pForObj) fctBlit.Surface->SetClr(pForObj->Color);
1000 
1001  if (!pMeshInstance)
1002  {
1003  // draw there
1004  C4DrawTransform trf(Transform, offX, offY);
1005  if (fZoomToShape)
1006  {
1007  assert(pForObj);
1008  float fZoom = std::min(pForObj->Shape.Wdt / std::max(fctBlit.Wdt, 1.0f), pForObj->Shape.Hgt / std::max(fctBlit.Hgt, 1.0f));
1009  trf.ScaleAt(fZoom, fZoom, offX, offY);
1010  }
1011 
1012  fctBlit.DrawT(cgo.Surface, offX - fctBlit.Wdt/2 + fctBlit.TargetX, offY - fctBlit.Hgt/2 + fctBlit.TargetY, iPhase, 0, &trf);
1013  }
1014  else
1015  {
1016  C4Def *pDef = pSourceGfx->pDef;
1017 
1018  // draw there
1019  C4DrawTransform trf(Transform, offX, offY);
1020  if (fZoomToShape)
1021  {
1022  assert(pForObj);
1023  float fZoom = std::min((float)pForObj->Shape.Wdt / std::max(pDef->Shape.Wdt, 1), (float)pForObj->Shape.Hgt / std::max(pDef->Shape.Hgt, 1));
1024  trf.ScaleAt(fZoom, fZoom, offX, offY);
1025  }
1026 
1027  C4Value value;
1028  pDef->GetProperty(P_MeshTransformation, &value);
1029  StdMeshMatrix matrix;
1030  if (C4ValueToMatrix(value, &matrix))
1031  pDraw->SetMeshTransform(&matrix);
1032 
1033  pDraw->RenderMesh(*pMeshInstance, cgo.Surface, offX - pDef->Shape.Wdt/2.0, offY - pDef->Shape.Hgt/2.0, pDef->Shape.Wdt, pDef->Shape.Hgt, pForObj ? pForObj->Color : 0xff, &trf);
1034  pDraw->SetMeshTransform(nullptr);
1035  }
1036  }
1037 
1038  // cleanup
1040  (OverlayObj ? static_cast<C4Object*>(OverlayObj) : pForObj)->FinishedDrawing();
1041  else
1042  {
1043  pDraw->ResetBlitMode();
1045  }
1046 }
void SetMeshTransform(const StdMeshMatrix *Transform)
Definition: C4Draw.h:200
C4DrawTransform * pDrawTransform
Definition: C4Object.h:137
float Y
Definition: C4Facet.h:120
float Zoom
Definition: C4Facet.h:167
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:103
void ResetBlitMode()
Definition: C4Draw.h:192
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:1800
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1148
void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform *transform=nullptr)
Definition: C4Object.cpp:2351
bool SetGraphics(const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
Definition: C4Object.cpp:4461
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:2060
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
int32_t Wdt
Definition: C4Rect.h:32
int32_t GetXOffset() const
Definition: C4Facet.h:111
bool RenderMesh(StdMeshInstance &instance, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)
Definition: C4Draw.cpp:406
C4Shape Shape
Definition: C4Def.h:106
int32_t y
Definition: C4Rect.h:32
void DrawT(C4Surface *sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform)
Definition: C4Facet.cpp:76
C4DefGraphics * GetGraphics() const
Definition: C4Object.h:340
void SetClr(DWORD toClr)
Definition: C4Surface.h:134
StdMeshInstance * pMeshInstance
void Set(const C4Facet &cpy)
Definition: C4Facet.h:184
uint32_t Color
Definition: C4Object.h:120
Definition: C4Def.h:100
C4Draw * pDraw
Definition: C4Draw.cpp:45
uint32_t dwClrModulation
void Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *trans)
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
float Hgt
Definition: C4Facet.h:120
void ScaleAt(float sx, float sy, float tx, float ty)
C4TargetFacet fctBlit
C4DrawTransform Transform
C4ObjectPtr OverlayObj
void DeactivateBlitModulation()
Definition: C4Draw.h:189
#define C4GFXBLIT_PARENT
Definition: C4Surface.h:38
int32_t GetYOffset() const
Definition: C4Facet.h:112
C4DefGraphics * pSourceGfx
void ActivateBlitModulation(DWORD dwWithClr)
Definition: C4Draw.h:188
int32_t Hgt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Object.h:148
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167
float Wdt
Definition: C4Facet.h:120
float X
Definition: C4Facet.h:120
bool C4ValueToMatrix(C4Value &value, StdMeshMatrix *matrix)
void DrawRankSymbol(C4Facet &cgo, C4Object *rank_obj)
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
Definition: C4Object.cpp:4345

Here is the call graph for this function:

void C4GraphicsOverlay::DrawPicture ( C4Facet cgo,
C4Object pForObj,
C4DrawTransform trans 
)

Definition at line 1069 of file C4DefGraphics.cpp.

References C4Draw::ActivateBlitModulation(), C4GFXBLIT_PARENT, C4Object::Color, C4Draw::DeactivateBlitModulation(), C4DefGraphics::Draw(), dwBlitMode, dwClrModulation, C4Object::FinishedDrawing(), C4Facet::Hgt, iPhase, IsPicture(), pDraw, pMeshInstance, C4Object::PrepareDrawing(), pSourceGfx, C4Draw::ResetBlitMode(), C4Draw::SetBlitMode(), StdMeshInstance::SetFaceOrderingForClrModulation(), Transform, C4Facet::Wdt, C4Facet::X, and C4Facet::Y.

1070 {
1071  assert(IsPicture());
1072 
1073  // special blit mode
1075  {
1076  if (pForObj) pForObj->PrepareDrawing();
1077  }
1078  else
1079  {
1082 
1083  if (pMeshInstance)
1085  }
1086 
1087  // the picture we are rendering is the one with trans applied, and the overlay transformation
1088  // is applied to the picture we are rendering, so apply it afterwards. Note that
1089  // C4BltTransform::operator*= does this = other * this.
1090  C4DrawTransform trf(Transform, cgo.X + cgo.Wdt/2.0f, cgo.Y + cgo.Hgt/2.0f);
1091  if(trans) trf *= *trans;
1092 
1093  // Don't set pForObj because we don't draw the picture of pForObj, but the picture of another definition on top of pForObj:
1094  pSourceGfx->Draw(cgo, pForObj->Color, nullptr, iPhase, 0, &trf);
1095 
1096  // cleanup
1098  {
1099  if (pForObj) pForObj->FinishedDrawing();
1100  }
1101  else
1102  {
1103  pDraw->ResetBlitMode();
1105  }
1106 }
float Y
Definition: C4Facet.h:120
void FinishedDrawing() const
Definition: C4Object.cpp:4140
void ResetBlitMode()
Definition: C4Draw.h:192
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1148
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
StdMeshInstance * pMeshInstance
uint32_t Color
Definition: C4Object.h:120
C4Draw * pDraw
Definition: C4Draw.cpp:45
uint32_t dwClrModulation
void PrepareDrawing() const
Definition: C4Object.cpp:4132
void Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *trans)
float Hgt
Definition: C4Facet.h:120
C4DrawTransform Transform
void DeactivateBlitModulation()
Definition: C4Draw.h:189
#define C4GFXBLIT_PARENT
Definition: C4Surface.h:38
C4DefGraphics * pSourceGfx
void ActivateBlitModulation(DWORD dwWithClr)
Definition: C4Draw.h:188
float Wdt
Definition: C4Facet.h:120
float X
Definition: C4Facet.h:120

Here is the call graph for this function:

void C4GraphicsOverlay::DrawRankSymbol ( C4Facet cgo,
C4Object rank_obj 
)

Definition at line 1048 of file C4DefGraphics.cpp.

References C4Object::Def, DefaultRanks, C4RankSystem::DrawRankSymbol(), C4GraphicsResource::fctRank, C4RankSystem::GetBaseRankNum(), GraphicsResource, C4Object::Info, C4GraphicsResource::iNumRanks, C4Def::iNumRankSymbols, C4Def::pRankNames, C4Def::pRankSymbols, and C4ObjectInfoCore::Rank.

Referenced by Draw().

1049 {
1050  // Determine source gfx for rank
1051  if (!rank_obj || !rank_obj->Info) return;
1052  C4RankSystem *pRankSys = &::DefaultRanks;
1053  C4Facet *pRankRes=&::GraphicsResource.fctRank;
1054  int iRankCnt=::GraphicsResource.iNumRanks;
1055  C4Def *rank_def=rank_obj->Def;
1056  if (rank_def->pRankSymbols)
1057  {
1058  pRankRes=rank_def->pRankSymbols;
1059  iRankCnt=rank_def->iNumRankSymbols;
1060  }
1061  if (rank_def->pRankNames)
1062  {
1063  pRankSys = rank_def->pRankNames;
1064  iRankCnt = rank_def->pRankNames->GetBaseRankNum();
1065  }
1066  pRankSys->DrawRankSymbol(nullptr, rank_obj->Info->Rank, pRankRes, iRankCnt, false, 0, &cgo);
1067 }
int32_t iNumRankSymbols
Definition: C4Def.h:193
C4RankSystem DefaultRanks
C4GraphicsResource GraphicsResource
int32_t GetBaseRankNum() const
Definition: C4RankSystem.h:52
C4ObjectInfo * Info
Definition: C4Object.h:145
C4Def * Def
Definition: C4Object.h:143
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr)
Definition: C4Def.h:100
C4FacetSurface * pRankSymbols
Definition: C4Def.h:192
C4RankSystem * pRankNames
Definition: C4Def.h:191

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t C4GraphicsOverlay::GetBlitMode ( ) const
inline

Definition at line 251 of file C4DefGraphics.h.

References dwBlitMode.

251 { return dwBlitMode; }
uint32_t C4GraphicsOverlay::GetClrModulation ( ) const
inline

Definition at line 248 of file C4DefGraphics.h.

References dwClrModulation.

248 { return dwClrModulation; }
uint32_t dwClrModulation
C4DefGraphics* C4GraphicsOverlay::GetGfx ( ) const
inline

Definition at line 240 of file C4DefGraphics.h.

References pSourceGfx.

Referenced by C4DefGraphicsPtrBackupEntry::AssignRemoval(), and C4DefGraphicsPtrBackupEntry::AssignUpdate().

240 { return pSourceGfx; }
C4DefGraphics * pSourceGfx

Here is the caller graph for this function:

int32_t C4GraphicsOverlay::GetID ( ) const
inline

Definition at line 234 of file C4DefGraphics.h.

References iID.

Referenced by C4DefGraphicsPtrBackupEntry::AssignRemoval(), C4DefGraphicsPtrBackupEntry::AssignUpdate(), C4Object::GetGraphicsOverlay(), and C4Object::RemoveGraphicsOverlay().

234 { return iID; }

Here is the caller graph for this function:

C4GraphicsOverlay* C4GraphicsOverlay::GetNext ( ) const
inline
C4Object* C4GraphicsOverlay::GetOverlayObject ( ) const
inline

Definition at line 233 of file C4DefGraphics.h.

References OverlayObj.

233 { return OverlayObj; }
C4ObjectPtr OverlayObj
C4DrawTransform* C4GraphicsOverlay::GetTransform ( )
inline

Definition at line 232 of file C4DefGraphics.h.

References Transform.

232 { return &Transform; }
C4DrawTransform Transform
bool C4GraphicsOverlay::IsPicture ( )
inline

Definition at line 239 of file C4DefGraphics.h.

References MODE_Picture.

Referenced by Draw(), and DrawPicture().

Here is the caller graph for this function:

bool C4GraphicsOverlay::IsValid ( const C4Object pForObj) const

Definition at line 818 of file C4DefGraphics.cpp.

References eMode, fctBlit, C4Object::HasGraphicsOverlayRecursion(), MODE_ExtraGraphics, MODE_IngamePicture, MODE_Object, MODE_ObjectPicture, MODE_Picture, MODE_Rank, OverlayObj, pMeshInstance, pSourceGfx, C4PropList::Status, C4Facet::Surface, C4DefGraphics::Type, C4DefGraphics::TYPE_Bitmap, and C4DefGraphics::TYPE_Mesh.

819 {
820  assert(pForObj);
822  {
823  if (!OverlayObj || !OverlayObj->Status) return false;
824  return (eMode == MODE_Rank) || !OverlayObj->HasGraphicsOverlayRecursion(pForObj);
825  }
826  else if (eMode == MODE_ExtraGraphics)
827  {
828  return !!pSourceGfx;
829  }
830  else if (pSourceGfx)
831  {
833  return true;
835  return !!fctBlit.Surface;
837  return !!pMeshInstance;
838  return false;
839  }
840  else
841  {
842  return false;
843  }
844 }
StdMeshInstance * pMeshInstance
int32_t Status
Definition: C4PropList.h:170
GraphicsType Type
Definition: C4DefGraphics.h:48
C4TargetFacet fctBlit
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx
C4Surface * Surface
Definition: C4Facet.h:119
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
Definition: C4Object.cpp:4535

Here is the call graph for this function:

bool C4GraphicsOverlay::operator== ( const C4GraphicsOverlay rCmp) const

Definition at line 1108 of file C4DefGraphics.cpp.

References Action, dwBlitMode, dwClrModulation, eMode, OverlayObj, pSourceGfx, SEqual(), and Transform.

1109 {
1110  // compare relevant fields
1111  // ignoring phase, because different animation state may be concatenated in graphics display
1112  return (eMode == rCmp.eMode)
1113  && (pSourceGfx == rCmp.pSourceGfx)
1114  && SEqual(Action, rCmp.Action)
1115  && (dwBlitMode == rCmp.dwBlitMode)
1116  && (dwClrModulation == rCmp.dwClrModulation)
1117  && (Transform == rCmp.Transform)
1118  && (OverlayObj == rCmp.OverlayObj);
1119 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
char Action[C4MaxName+1]
uint32_t dwClrModulation
C4DrawTransform Transform
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx

Here is the call graph for this function:

void C4GraphicsOverlay::Set ( Mode  aMode,
C4DefGraphics pGfx,
const char *  szAction,
DWORD  dwBMode,
C4Object pOvrlObj 
)
protected

Definition at line 803 of file C4DefGraphics.cpp.

References Action, C4MaxName, dwBlitMode, eMode, iPhase, OverlayObj, pSourceGfx, SCopy(), and UpdateFacet().

Referenced by SetAsAction(), SetAsBase(), SetAsExtraGraphics(), SetAsIngamePicture(), SetAsObject(), SetAsObjectPicture(), SetAsPicture(), and SetAsRank().

804 {
805  // set values
806  eMode = aMode;
807  pSourceGfx = pGfx;
808  if (szAction) SCopy(szAction, Action, C4MaxName); else *Action=0;
809  dwBlitMode = dwBMode;
810  OverlayObj = pOvrlObj;
811  // (keep transform)
812  // reset phase
813  iPhase = 0;
814  // update used facet
815  UpdateFacet();
816 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
char Action[C4MaxName+1]
const unsigned int C4MaxName
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsOverlay::SetAsAction ( C4DefGraphics pBaseGfx,
const char *  szAction,
DWORD  dwBMode 
)
inline

Definition at line 215 of file C4DefGraphics.h.

References MODE_Action, and Set().

216  { Set(MODE_Action, pBaseGfx, szAction, dwBMode, nullptr); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsBase ( C4DefGraphics pBaseGfx,
DWORD  dwBMode 
)
inline

Definition at line 213 of file C4DefGraphics.h.

References MODE_Base, and Set().

214  { Set(MODE_Base, pBaseGfx, nullptr, dwBMode, nullptr); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsExtraGraphics ( C4DefGraphics pGfx,
DWORD  dwBMode 
)
inline

Definition at line 225 of file C4DefGraphics.h.

References MODE_ExtraGraphics, and Set().

226  { Set(MODE_ExtraGraphics, pGfx, nullptr, dwBMode, nullptr); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsIngamePicture ( C4DefGraphics pBaseGfx,
DWORD  dwBMode 
)
inline

Definition at line 219 of file C4DefGraphics.h.

References MODE_IngamePicture, and Set().

220  { Set(MODE_IngamePicture, pBaseGfx, nullptr, dwBMode, nullptr); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsObject ( C4Object pOverlayObj,
DWORD  dwBMode 
)
inline

Definition at line 221 of file C4DefGraphics.h.

References MODE_Object, and Set().

222  { Set(MODE_Object, nullptr, nullptr, dwBMode, pOverlayObj); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsObjectPicture ( C4Object pOverlayObj,
DWORD  dwBMode 
)
inline

Definition at line 223 of file C4DefGraphics.h.

References MODE_ObjectPicture, and Set().

224  { Set(MODE_ObjectPicture, nullptr, nullptr, dwBMode, pOverlayObj); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsPicture ( C4DefGraphics pBaseGfx,
DWORD  dwBMode 
)
inline

Definition at line 217 of file C4DefGraphics.h.

References MODE_Picture, and Set().

218  { Set(MODE_Picture, pBaseGfx, nullptr, dwBMode, nullptr); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetAsRank ( DWORD  dwBMode,
C4Object rank_obj 
)
inline

Definition at line 227 of file C4DefGraphics.h.

References MODE_Rank, and Set().

228  { Set(MODE_Rank, nullptr, nullptr, dwBMode, rank_obj); }
void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj)

Here is the call graph for this function:

void C4GraphicsOverlay::SetBlitMode ( uint32_t  dwToMode)
inline

Definition at line 252 of file C4DefGraphics.h.

252 { dwBlitMode = dwToMode; }
void C4GraphicsOverlay::SetClrModulation ( uint32_t  dwToMod)
inline

Definition at line 249 of file C4DefGraphics.h.

249 { dwClrModulation = dwToMod; }
uint32_t dwClrModulation
void C4GraphicsOverlay::SetID ( int32_t  aID)
inline

Definition at line 235 of file C4DefGraphics.h.

Referenced by C4Object::GetGraphicsOverlay().

235 { iID = aID; }

Here is the caller graph for this function:

void C4GraphicsOverlay::SetNext ( C4GraphicsOverlay paNext)
inline

Definition at line 238 of file C4DefGraphics.h.

Referenced by C4GraphicsOverlayListAdapt::CompileFunc(), C4Object::GetGraphicsOverlay(), and C4Object::RemoveGraphicsOverlay().

238 { pNext = paNext; }
C4GraphicsOverlay * pNext

Here is the caller graph for this function:

void C4GraphicsOverlay::SetPhase ( int32_t  iToPhase)
void C4GraphicsOverlay::UpdateFacet ( )
protected

Definition at line 713 of file C4DefGraphics.cpp.

References Action, C4TargetFacet::Default(), eMode, fctBlit, ftofix(), fZoomToShape, C4DefGraphics::GetBitmap(), C4String::GetData(), C4PropList::GetProperty(), C4PropList::GetPropertyByS(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyStr(), C4Value::getPropList(), C4Rect::Hgt, iPhase, itofix(), StdMeshAnimation::Length, MODE_Action, MODE_Base, MODE_ExtraGraphics, MODE_IngamePicture, MODE_None, MODE_Object, MODE_ObjectPicture, MODE_Picture, MODE_Rank, P_ActMap, P_Animation, P_Hgt, P_Length, P_Wdt, P_X, P_Y, C4DefGraphics::pDef, StdMeshInstance::PlayAnimation(), pMeshInstance, pSourceGfx, C4StringTable::RegString(), C4TargetFacet::Set(), C4Def::Shape, Strings, C4DefGraphics::Type, C4DefGraphics::TYPE_Bitmap, C4DefGraphics::TYPE_Mesh, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by CompileFunc(), and Set().

714 {
715  // special: Nothing to update for object and pSourceGfx may be nullptr
716  // If there will ever be something to init here, UpdateFacet() will also need to be called when objects have been loaded
717  if (eMode == MODE_Object) return;
718  // otherwise, source graphics must be specified
719  if (!pSourceGfx) return;
720  C4Def *pDef = pSourceGfx->pDef;
721  assert(pDef);
722  fZoomToShape = false;
723  // Clear old mesh instance, if any
724  delete pMeshInstance; pMeshInstance = nullptr;
725  // update by mode
726  switch (eMode)
727  {
728  case MODE_None:
729  break;
730 
731  case MODE_Base: // def base graphics
733  fctBlit.Set(pSourceGfx->GetBitmap(), 0, 0, pDef->Shape.Wdt, pDef->Shape.Hgt, pDef->Shape.x+pDef->Shape.Wdt/2, pDef->Shape.y+pDef->Shape.Hgt/2);
735  pMeshInstance = new StdMeshInstance(*pSourceGfx->Mesh, 1.0f);
736  break;
737 
738  case MODE_Action: // graphics of specified action
739  {
740  // Clear old facet
741  fctBlit.Default();
742 
743  // Ensure there is actually an action set
744  if (!Action[0])
745  return;
746 
747  C4Value v;
748  pDef->GetProperty(P_ActMap, &v);
749  C4PropList *actmap = v.getPropList();
750  if (!actmap)
751  return;
752 
753  actmap->GetPropertyByS(::Strings.RegString(Action), &v);
754  C4PropList *action = v.getPropList();
755  if (!action)
756  return;
757 
759  {
761  action->GetPropertyInt(P_X), action->GetPropertyInt(P_Y),
762  action->GetPropertyInt(P_Wdt), action->GetPropertyInt(P_Hgt));
763  // FIXME: fctBlit.TargetX has to be set here
764  }
766  {
767  C4String* AnimationName = action->GetPropertyStr(P_Animation);
768  if (!AnimationName) return;
769 
770  pMeshInstance = new StdMeshInstance(*pSourceGfx->Mesh, 1.0f);
771  const StdMeshAnimation* Animation = pSourceGfx->Mesh->GetSkeleton().GetAnimationByName(AnimationName->GetData());
772  if (!Animation) return;
773 
774  pMeshInstance->PlayAnimation(*Animation, 0, nullptr, new C4ValueProviderRef<int32_t>(iPhase, ftofix(Animation->Length / action->GetPropertyInt(P_Length))), new C4ValueProviderConst(itofix(1)), true);
775  }
776 
777  break;
778  }
779  case MODE_ObjectPicture: // ingame picture of object
780  // calculated at runtime
781  break;
782 
783  case MODE_IngamePicture:
784  case MODE_Picture: // def picture
785  fZoomToShape = true;
786  // drawn at runtime
787  break;
788 
789  case MODE_ExtraGraphics: // like ColorByOwner-sfc
790  // calculated at runtime
791  break;
792 
793  case MODE_Rank:
794  // drawn at runtime
795  break;
796 
797  case MODE_Object:
798  // TODO
799  break;
800  }
801 }
StdStrBuf GetData() const
Definition: C4StringTable.h:50
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:103
C4String * RegString(StdStrBuf String)
int32_t Wdt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Def.h:106
char Action[C4MaxName+1]
AnimationNode * PlayAnimation(const StdStrBuf &animation_name, int slot, AnimationNode *sibling, ValueProvider *position, ValueProvider *weight, bool stop_previous_animation)
Definition: StdMesh.cpp:1180
int32_t y
Definition: C4Rect.h:32
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:734
C4Surface * GetBitmap(DWORD dwClr=0)
StdMeshInstance * pMeshInstance
void Set(const C4Facet &cpy)
Definition: C4Facet.h:184
Definition: C4Def.h:100
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
C4Fixed ftofix(float x)
Definition: C4Real.h:258
int32_t x
Definition: C4Rect.h:32
void Default()
Definition: C4Facet.h:181
GraphicsType Type
Definition: C4DefGraphics.h:48
C4TargetFacet fctBlit
C4DefGraphics * pSourceGfx
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:863
int32_t Hgt
Definition: C4Rect.h:32
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:752
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4DefGraphicsPtrBackup
friend

Definition at line 167 of file C4DefGraphics.h.

friend class C4DefGraphicsPtrBackupEntry
friend

Definition at line 166 of file C4DefGraphics.h.

Member Data Documentation

char C4GraphicsOverlay::Action[C4MaxName+1]
protected

Definition at line 185 of file C4DefGraphics.h.

Referenced by CompileFunc(), operator==(), Set(), and UpdateFacet().

uint32_t C4GraphicsOverlay::dwBlitMode
protected

Definition at line 188 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), DrawPicture(), GetBlitMode(), operator==(), and Set().

uint32_t C4GraphicsOverlay::dwClrModulation
protected

Definition at line 189 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), DrawPicture(), GetClrModulation(), and operator==().

Mode C4GraphicsOverlay::eMode
protected

Definition at line 182 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), IsValid(), operator==(), Set(), and UpdateFacet().

C4TargetFacet C4GraphicsOverlay::fctBlit
protected

Definition at line 186 of file C4DefGraphics.h.

Referenced by Draw(), IsValid(), and UpdateFacet().

bool C4GraphicsOverlay::fZoomToShape
protected

Definition at line 193 of file C4DefGraphics.h.

Referenced by Draw(), and UpdateFacet().

int32_t C4GraphicsOverlay::iID
protected

Definition at line 195 of file C4DefGraphics.h.

Referenced by CompileFunc(), and GetID().

int32_t C4GraphicsOverlay::iPhase
protected

Definition at line 192 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), DrawPicture(), Set(), and UpdateFacet().

C4ObjectPtr C4GraphicsOverlay::OverlayObj
protected
StdMeshInstance* C4GraphicsOverlay::pMeshInstance
protected

Definition at line 187 of file C4DefGraphics.h.

Referenced by Draw(), DrawPicture(), IsValid(), UpdateFacet(), and ~C4GraphicsOverlay().

C4GraphicsOverlay* C4GraphicsOverlay::pNext
protected

Definition at line 197 of file C4DefGraphics.h.

Referenced by GetNext(), and ~C4GraphicsOverlay().

C4DefGraphics* C4GraphicsOverlay::pSourceGfx
protected

Definition at line 184 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), DrawPicture(), GetGfx(), IsValid(), operator==(), Set(), and UpdateFacet().

C4DrawTransform C4GraphicsOverlay::Transform
protected

Definition at line 191 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), DrawPicture(), GetTransform(), and operator==().


The documentation for this class was generated from the following files: