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 {MODE_None}
 
C4DefGraphicspSourceGfx {nullptr}
 
char Action [C4MaxName+1]
 
C4TargetFacet fctBlit
 
StdMeshInstancepMeshInstance {nullptr}
 
uint32_t dwBlitMode {0}
 
uint32_t dwClrModulation {0xffffff}
 
C4ObjectPtr OverlayObj
 
C4DrawTransform Transform
 
int32_t iPhase {0}
 
bool fZoomToShape {false}
 
int32_t iID {0}
 
C4GraphicsOverlaypNext {nullptr}
 

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  : fctBlit(),
204  OverlayObj(nullptr), Transform(+1) { *Action=0; } // std ctor
char Action[C4MaxName+1]
C4TargetFacet fctBlit
C4DrawTransform Transform
C4ObjectPtr OverlayObj
C4GraphicsOverlay::~C4GraphicsOverlay ( )

Definition at line 694 of file C4DefGraphics.cpp.

References pMeshInstance, and pNext.

695 {
696  // Free mesh instance
697  delete pMeshInstance; pMeshInstance = nullptr;
698  // free any additional overlays
699  C4GraphicsOverlay *pNextOther = pNext, *pOther;
700  while ((pOther = pNextOther))
701  {
702  pNextOther = pOther->pNext;
703  pOther->pNext = nullptr;
704  delete pOther;
705  }
706 }
C4GraphicsOverlay * pNext
StdMeshInstance * pMeshInstance

Member Function Documentation

void C4GraphicsOverlay::CompileFunc ( StdCompiler pComp)

Definition at line 841 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().

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

Here is the call graph for this function:

void C4GraphicsOverlay::DenumeratePointers ( )

Definition at line 876 of file C4DefGraphics.cpp.

References C4ObjectPtr::DenumeratePointers(), and OverlayObj.

877 {
879 }
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:47
C4ObjectPtr OverlayObj

Here is the call graph for this function:

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

Definition at line 881 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.

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

Here is the call graph for this function:

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

Definition at line 1064 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.

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

Here is the call graph for this function:

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

Definition at line 1043 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().

1044 {
1045  // Determine source gfx for rank
1046  if (!rank_obj || !rank_obj->Info) return;
1047  C4RankSystem *pRankSys = &::DefaultRanks;
1048  C4Facet *pRankRes=&::GraphicsResource.fctRank;
1049  int iRankCnt=::GraphicsResource.iNumRanks;
1050  C4Def *rank_def=rank_obj->Def;
1051  if (rank_def->pRankSymbols)
1052  {
1053  pRankRes=rank_def->pRankSymbols;
1054  iRankCnt=rank_def->iNumRankSymbols;
1055  }
1056  if (rank_def->pRankNames)
1057  {
1058  pRankSys = rank_def->pRankNames;
1059  iRankCnt = rank_def->pRankNames->GetBaseRankNum();
1060  }
1061  pRankSys->DrawRankSymbol(nullptr, rank_obj->Info->Rank, pRankRes, iRankCnt, false, 0, &cgo);
1062 }
int32_t iNumRankSymbols
Definition: C4Def.h:191
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:98
C4FacetSurface * pRankSymbols
Definition: C4Def.h:190
C4RankSystem * pRankNames
Definition: C4Def.h:189

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 250 of file C4DefGraphics.h.

References dwBlitMode.

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

Definition at line 247 of file C4DefGraphics.h.

References dwClrModulation.

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

Definition at line 239 of file C4DefGraphics.h.

References pSourceGfx.

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

239 { return pSourceGfx; }
C4DefGraphics * pSourceGfx

Here is the caller graph for this function:

int32_t C4GraphicsOverlay::GetID ( ) const
inline

Definition at line 233 of file C4DefGraphics.h.

References iID.

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

233 { return iID; }

Here is the caller graph for this function:

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

Definition at line 232 of file C4DefGraphics.h.

References OverlayObj.

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

Definition at line 231 of file C4DefGraphics.h.

References Transform.

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

Definition at line 238 of file C4DefGraphics.h.

References eMode, and 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 813 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.

814 {
815  assert(pForObj);
817  {
818  if (!OverlayObj || !OverlayObj->Status) return false;
819  return (eMode == MODE_Rank) || !OverlayObj->HasGraphicsOverlayRecursion(pForObj);
820  }
821  else if (eMode == MODE_ExtraGraphics)
822  {
823  return !!pSourceGfx;
824  }
825  else if (pSourceGfx)
826  {
828  return true;
830  return !!fctBlit.Surface;
832  return !!pMeshInstance;
833  return false;
834  }
835  else
836  {
837  return false;
838  }
839 }
StdMeshInstance * pMeshInstance
int32_t Status
Definition: C4PropList.h:168
GraphicsType Type
Definition: C4DefGraphics.h:48
C4TargetFacet fctBlit
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx
C4Surface * Surface
Definition: C4Facet.h:117
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
Definition: C4Object.cpp:4524

Here is the call graph for this function:

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

Definition at line 1103 of file C4DefGraphics.cpp.

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

1104 {
1105  // compare relevant fields
1106  // ignoring phase, because different animation state may be concatenated in graphics display
1107  return (eMode == rCmp.eMode)
1108  && (pSourceGfx == rCmp.pSourceGfx)
1109  && SEqual(Action, rCmp.Action)
1110  && (dwBlitMode == rCmp.dwBlitMode)
1111  && (dwClrModulation == rCmp.dwClrModulation)
1112  && (Transform == rCmp.Transform)
1113  && (OverlayObj == rCmp.OverlayObj);
1114 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
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 798 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().

799 {
800  // set values
801  eMode = aMode;
802  pSourceGfx = pGfx;
803  if (szAction) SCopy(szAction, Action, C4MaxName); else *Action=0;
804  dwBlitMode = dwBMode;
805  OverlayObj = pOvrlObj;
806  // (keep transform)
807  // reset phase
808  iPhase = 0;
809  // update used facet
810  UpdateFacet();
811 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
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 214 of file C4DefGraphics.h.

References MODE_Action, and Set().

215  { 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 212 of file C4DefGraphics.h.

References MODE_Base, and Set().

213  { 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 224 of file C4DefGraphics.h.

References MODE_ExtraGraphics, and Set().

225  { 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 218 of file C4DefGraphics.h.

References MODE_IngamePicture, and Set().

219  { 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 220 of file C4DefGraphics.h.

References MODE_Object, and Set().

221  { 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 222 of file C4DefGraphics.h.

References MODE_ObjectPicture, and Set().

223  { 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 216 of file C4DefGraphics.h.

References MODE_Picture, and Set().

217  { 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 226 of file C4DefGraphics.h.

References MODE_Rank, and Set().

227  { 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 251 of file C4DefGraphics.h.

References dwBlitMode.

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

Definition at line 248 of file C4DefGraphics.h.

References dwClrModulation.

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

Definition at line 234 of file C4DefGraphics.h.

References iID.

Referenced by C4Object::GetGraphicsOverlay().

234 { iID = aID; }

Here is the caller graph for this function:

void C4GraphicsOverlay::SetNext ( C4GraphicsOverlay paNext)
inline

Definition at line 237 of file C4DefGraphics.h.

References pNext.

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

237 { 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 708 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().

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

Definition at line 188 of file C4DefGraphics.h.

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

uint32_t C4GraphicsOverlay::dwClrModulation {0xffffff}
protected
Mode C4GraphicsOverlay::eMode {MODE_None}
protected

Definition at line 182 of file C4DefGraphics.h.

Referenced by CompileFunc(), Draw(), IsPicture(), 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 {false}
protected

Definition at line 193 of file C4DefGraphics.h.

Referenced by Draw(), and UpdateFacet().

int32_t C4GraphicsOverlay::iID {0}
protected

Definition at line 195 of file C4DefGraphics.h.

Referenced by CompileFunc(), GetID(), and SetID().

int32_t C4GraphicsOverlay::iPhase {0}
protected

Definition at line 192 of file C4DefGraphics.h.

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

C4ObjectPtr C4GraphicsOverlay::OverlayObj
protected
StdMeshInstance* C4GraphicsOverlay::pMeshInstance {nullptr}
protected

Definition at line 187 of file C4DefGraphics.h.

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

C4GraphicsOverlay* C4GraphicsOverlay::pNext {nullptr}
protected

Definition at line 197 of file C4DefGraphics.h.

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

C4DefGraphics* C4GraphicsOverlay::pSourceGfx {nullptr}
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: