OpenClonk
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

◆ Mode

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::C4GraphicsOverlay ( )
inline

Definition at line 203 of file C4DefGraphics.h.

References C4DefGraphics::CompileFunc().

203  : fctBlit(),
204  OverlayObj(nullptr), Transform(+1) { *Action=0; } // std ctor
char Action[C4MaxName+1]
C4TargetFacet fctBlit
C4DrawTransform Transform
C4ObjectPtr OverlayObj
Here is the call graph for this function:

◆ ~C4GraphicsOverlay()

C4GraphicsOverlay::~C4GraphicsOverlay ( )

Definition at line 694 of file C4DefGraphics.cpp.

References 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

◆ CompileFunc()

void C4GraphicsOverlay::CompileFunc ( StdCompiler pComp)

Definition at line 841 of file C4DefGraphics.cpp.

References StdCompiler::isDeserializer(), mkDefaultAdapt(), mkIntAdapt(), mkStringAdaptMIE, StdCompiler::SEP_END, StdCompiler::SEP_START, StdCompiler::Separator(), 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:247
#define mkStringAdaptMIE(szString)
Definition: StdAdaptors.h:192
Here is the call graph for this function:

◆ DenumeratePointers()

void C4GraphicsOverlay::DenumeratePointers ( )

Definition at line 876 of file C4DefGraphics.cpp.

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

◆ Draw()

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(), C4Object::Draw(), C4Object::DrawTopFace(), C4Object::GetDrawPosition(), C4Object::GetGraphics(), C4PropList::GetProperty(), C4Rect::Hgt, C4Facet::Hgt, C4Object::ODM_BaseOnly, C4Object::ODM_Overlay, P_MeshTransformation, pDraw, C4Object::pDrawTransform, C4Draw::RenderMesh(), C4Draw::ResetBlitMode(), C4BltTransform::ScaleAt(), C4Facet::Set(), C4TargetFacet::Set(), C4Draw::SetBlitMode(), C4Object::SetGraphics(), C4Draw::SetMeshTransform(), C4Def::Shape, C4Object::Shape, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Surface::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
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:1788
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:4453
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:101
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:2048
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
C4DefGraphics * GetGraphics() const
Definition: C4Object.h:341
int32_t Wdt
Definition: C4Rect.h:30
int32_t GetYOffset() const
Definition: C4Facet.h:110
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
int32_t GetXOffset() const
Definition: C4Facet.h:109
void DrawT(C4Surface *sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform)
Definition: C4Facet.cpp:76
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
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
Definition: C4Object.cpp:4337
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
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)
Here is the call graph for this function:

◆ DrawPicture()

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(), C4Object::FinishedDrawing(), C4Facet::Hgt, pDraw, C4Object::PrepareDrawing(), C4Draw::ResetBlitMode(), C4Draw::SetBlitMode(), C4Facet::Wdt, C4Facet::X, and C4Facet::Y.

Referenced by C4Object::AddCommand().

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 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 Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *trans)
void PrepareDrawing() const
Definition: C4Object.cpp:4123
float Hgt
Definition: C4Facet.h:118
C4DrawTransform Transform
void FinishedDrawing() const
Definition: C4Object.cpp:4131
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:
Here is the caller graph for this function:

◆ DrawRankSymbol()

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.

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:190
int32_t GetBaseRankNum() const
Definition: C4RankSystem.h:52
C4RankSystem DefaultRanks
C4GraphicsResource GraphicsResource
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:189
C4RankSystem * pRankNames
Definition: C4Def.h:188
Here is the call graph for this function:

◆ GetBlitMode()

uint32_t C4GraphicsOverlay::GetBlitMode ( ) const
inline

Definition at line 250 of file C4DefGraphics.h.

250 { return dwBlitMode; }

◆ GetClrModulation()

uint32_t C4GraphicsOverlay::GetClrModulation ( ) const
inline

Definition at line 247 of file C4DefGraphics.h.

247 { return dwClrModulation; }
uint32_t dwClrModulation

◆ GetGfx()

C4DefGraphics* C4GraphicsOverlay::GetGfx ( ) const
inline

Definition at line 239 of file C4DefGraphics.h.

References C4DefGraphics::Draw(), and operator==().

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

239 { return pSourceGfx; }
C4DefGraphics * pSourceGfx
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetID()

int32_t C4GraphicsOverlay::GetID ( ) const
inline

Definition at line 233 of file C4DefGraphics.h.

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

233 { return iID; }
Here is the caller graph for this function:

◆ GetNext()

◆ GetOverlayObject()

C4Object* C4GraphicsOverlay::GetOverlayObject ( ) const
inline

Definition at line 232 of file C4DefGraphics.h.

232 { return OverlayObj; }
C4ObjectPtr OverlayObj

◆ GetTransform()

C4DrawTransform* C4GraphicsOverlay::GetTransform ( )
inline

Definition at line 231 of file C4DefGraphics.h.

231 { return &Transform; }
C4DrawTransform Transform

◆ IsPicture()

bool C4GraphicsOverlay::IsPicture ( )
inline

Definition at line 238 of file C4DefGraphics.h.

◆ IsValid()

bool C4GraphicsOverlay::IsValid ( const C4Object pForObj) const

Definition at line 813 of file C4DefGraphics.cpp.

References 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 }
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
Definition: C4Object.cpp:4527
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

◆ operator==()

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:

◆ Set()

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

Definition at line 798 of file C4DefGraphics.cpp.

References C4MaxName, and SCopy().

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:152
char Action[C4MaxName+1]
const unsigned int C4MaxName
C4ObjectPtr OverlayObj
C4DefGraphics * pSourceGfx
Here is the call graph for this function:

◆ SetAsAction()

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

Definition at line 214 of file C4DefGraphics.h.

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

◆ SetAsBase()

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

Definition at line 212 of file C4DefGraphics.h.

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

◆ SetAsExtraGraphics()

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

Definition at line 224 of file C4DefGraphics.h.

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

◆ SetAsIngamePicture()

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

Definition at line 218 of file C4DefGraphics.h.

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

◆ SetAsObject()

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

Definition at line 220 of file C4DefGraphics.h.

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

◆ SetAsObjectPicture()

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

Definition at line 222 of file C4DefGraphics.h.

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

◆ SetAsPicture()

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

Definition at line 216 of file C4DefGraphics.h.

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

◆ SetAsRank()

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

Definition at line 226 of file C4DefGraphics.h.

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

◆ SetBlitMode()

void C4GraphicsOverlay::SetBlitMode ( uint32_t  dwToMode)
inline

Definition at line 251 of file C4DefGraphics.h.

251 { dwBlitMode = dwToMode; }

◆ SetClrModulation()

void C4GraphicsOverlay::SetClrModulation ( uint32_t  dwToMod)
inline

Definition at line 248 of file C4DefGraphics.h.

248 { dwClrModulation = dwToMod; }
uint32_t dwClrModulation

◆ SetID()

void C4GraphicsOverlay::SetID ( int32_t  aID)
inline

Definition at line 234 of file C4DefGraphics.h.

Referenced by C4Object::GetGraphicsOverlay().

234 { iID = aID; }
Here is the caller graph for this function:

◆ SetNext()

void C4GraphicsOverlay::SetNext ( C4GraphicsOverlay paNext)
inline

Definition at line 237 of file C4DefGraphics.h.

References C4DefGraphics::pNext.

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

237 { pNext = paNext; }
C4GraphicsOverlay * pNext
Here is the caller graph for this function:

◆ SetPhase()

void C4GraphicsOverlay::SetPhase ( int32_t  iToPhase)

Referenced by C4Object::AddCommand().

Here is the caller graph for this function:

◆ UpdateFacet()

void C4GraphicsOverlay::UpdateFacet ( )
protected

Definition at line 708 of file C4DefGraphics.cpp.

References ftofix(), C4String::GetData(), C4PropList::GetProperty(), C4PropList::GetPropertyByS(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyStr(), C4Value::getPropList(), C4Rect::Hgt, itofix(), StdMeshAnimation::Length, P_ActMap, P_Animation, P_Hgt, P_Length, P_Wdt, P_X, P_Y, C4StringTable::RegString(), C4Def::Shape, Strings, C4DefGraphics::TYPE_Bitmap, C4DefGraphics::TYPE_Mesh, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

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 }
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
StdStrBuf GetData() const
Definition: C4StringTable.h:50
C4PropList * getPropList() const
Definition: C4Value.h:116
C4String * RegString(StdStrBuf String)
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:101
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
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 Hgt
Definition: C4Rect.h:30
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
float Length
Definition: StdMesh.h:98
Here is the call graph for this function:

Friends And Related Function Documentation

◆ C4DefGraphicsPtrBackup

friend class C4DefGraphicsPtrBackup
friend

Definition at line 167 of file C4DefGraphics.h.

◆ C4DefGraphicsPtrBackupEntry

friend class C4DefGraphicsPtrBackupEntry
friend

Definition at line 166 of file C4DefGraphics.h.

Member Data Documentation

◆ Action

char C4GraphicsOverlay::Action[C4MaxName+1]
protected

Definition at line 185 of file C4DefGraphics.h.

Referenced by operator==().

◆ dwBlitMode

uint32_t C4GraphicsOverlay::dwBlitMode {0}
protected

Definition at line 188 of file C4DefGraphics.h.

Referenced by operator==().

◆ dwClrModulation

uint32_t C4GraphicsOverlay::dwClrModulation {0xffffff}
protected

Definition at line 189 of file C4DefGraphics.h.

Referenced by operator==().

◆ eMode

Mode C4GraphicsOverlay::eMode {MODE_None}
protected

Definition at line 182 of file C4DefGraphics.h.

Referenced by operator==().

◆ fctBlit

C4TargetFacet C4GraphicsOverlay::fctBlit
protected

Definition at line 186 of file C4DefGraphics.h.

◆ fZoomToShape

bool C4GraphicsOverlay::fZoomToShape {false}
protected

Definition at line 193 of file C4DefGraphics.h.

◆ iID

int32_t C4GraphicsOverlay::iID {0}
protected

Definition at line 195 of file C4DefGraphics.h.

◆ iPhase

int32_t C4GraphicsOverlay::iPhase {0}
protected

Definition at line 192 of file C4DefGraphics.h.

Referenced by C4Object::AddCommand().

◆ OverlayObj

C4ObjectPtr C4GraphicsOverlay::OverlayObj
protected

Definition at line 190 of file C4DefGraphics.h.

Referenced by operator==().

◆ pMeshInstance

StdMeshInstance* C4GraphicsOverlay::pMeshInstance {nullptr}
protected

Definition at line 187 of file C4DefGraphics.h.

◆ pNext

C4GraphicsOverlay* C4GraphicsOverlay::pNext {nullptr}
protected

Definition at line 197 of file C4DefGraphics.h.

Referenced by ~C4GraphicsOverlay().

◆ pSourceGfx

C4DefGraphics* C4GraphicsOverlay::pSourceGfx {nullptr}
protected

Definition at line 184 of file C4DefGraphics.h.

Referenced by operator==().

◆ Transform

C4DrawTransform C4GraphicsOverlay::Transform
protected

Definition at line 191 of file C4DefGraphics.h.

Referenced by operator==().


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