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.

203  : fctBlit(),
204  OverlayObj(nullptr), Transform(+1) { *Action=0; } // std ctor
C4ObjectPtr OverlayObj
C4DrawTransform Transform
char Action[C4MaxName+1]
C4TargetFacet fctBlit

References Action.

◆ ~C4GraphicsOverlay()

C4GraphicsOverlay::~C4GraphicsOverlay ( )

Definition at line 694 of file C4DefGraphics.cpp.

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

References pMeshInstance, and pNext.

Member Function Documentation

◆ CompileFunc()

void C4GraphicsOverlay::CompileFunc ( StdCompiler pComp)

Definition at line 841 of file C4DefGraphics.cpp.

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 }
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:64
StdIntAdapt< T > mkIntAdapt(T &rValue)
Definition: StdAdaptors.h:255
StdStringAdapt mkStringAdaptMIE(char(&szString)[size])
Definition: StdAdaptors.h:192
C4DefGraphics * pSourceGfx
uint32_t dwClrModulation
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

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().

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:49

References C4ObjectPtr::DenumeratePointers(), and OverlayObj.

Here is the call graph for this function:

◆ Draw()

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

Definition at line 881 of file C4DefGraphics.cpp.

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 }
C4Draw * pDraw
Definition: C4Draw.cpp:42
bool C4ValueToMatrix(C4Value &value, StdMeshMatrix *matrix)
@ P_MeshTransformation
#define C4GFXBLIT_PARENT
Definition: C4Surface.h:36
void ScaleAt(float sx, float sy, float tx, float ty)
void Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *trans)
Definition: C4Def.h:99
C4Shape Shape
Definition: C4Def.h:104
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
bool RenderMesh(StdMeshInstance &instance, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)
Definition: C4Draw.cpp:397
void DeactivateBlitModulation()
Definition: C4Draw.h:189
void SetMeshTransform(const StdMeshMatrix *Transform)
Definition: C4Draw.h:200
void ResetBlitMode()
Definition: C4Draw.h:192
void ActivateBlitModulation(DWORD dwWithClr)
Definition: C4Draw.h:188
int32_t GetXOffset() const
Definition: C4Facet.h:109
int32_t GetYOffset() const
Definition: C4Facet.h:110
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
void DrawT(C4Surface *sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform)
Definition: C4Facet.cpp:76
C4Surface * Surface
Definition: C4Facet.h:117
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
float Y
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
void DrawRankSymbol(C4Facet &cgo, C4Object *rank_obj)
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
bool SetGraphics(const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform *transform=nullptr)
C4DrawTransform * pDrawTransform
Definition: C4Object.h:135
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
@ ODM_Overlay
Definition: C4Object.h:215
@ ODM_BaseOnly
Definition: C4Object.h:215
uint32_t Color
Definition: C4Object.h:118
C4Shape Shape
Definition: C4Object.h:146
C4DefGraphics * GetGraphics() const
Definition: C4Object.h:339
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:105
int32_t y
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
void SetClr(DWORD toClr)
Definition: C4Surface.h:132
float TargetY
Definition: C4Facet.h:165
float TargetX
Definition: C4Facet.h:165
float Zoom
Definition: C4Facet.h:165
void Set(const C4Facet &cpy)
Definition: C4Facet.h:182
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1135

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(), C4Facet::Hgt, C4Rect::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, C4Facet::Wdt, C4Rect::Wdt, C4Facet::X, C4Rect::x, C4Facet::Y, C4Rect::y, and C4TargetFacet::Zoom.

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.

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 }
void PrepareDrawing() const
void FinishedDrawing() const

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.

Here is the call graph for this function:

◆ DrawRankSymbol()

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

Definition at line 1043 of file C4DefGraphics.cpp.

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 }
C4GraphicsResource GraphicsResource
C4RankSystem DefaultRanks
int32_t iNumRankSymbols
Definition: C4Def.h:190
C4FacetSurface * pRankSymbols
Definition: C4Def.h:189
C4RankSystem * pRankNames
Definition: C4Def.h:188
C4ObjectInfo * Info
Definition: C4Object.h:143
C4Def * Def
Definition: C4Object.h:141
int32_t GetBaseRankNum() const
Definition: C4RankSystem.h:52
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlitMode()

uint32_t C4GraphicsOverlay::GetBlitMode ( ) const
inline

Definition at line 250 of file C4DefGraphics.h.

250 { return dwBlitMode; }

References dwBlitMode.

◆ GetClrModulation()

uint32_t C4GraphicsOverlay::GetClrModulation ( ) const
inline

Definition at line 247 of file C4DefGraphics.h.

247 { return dwClrModulation; }

References dwClrModulation.

◆ GetGfx()

C4DefGraphics* C4GraphicsOverlay::GetGfx ( ) const
inline

Definition at line 239 of file C4DefGraphics.h.

239 { return pSourceGfx; }

References pSourceGfx.

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

Here is the caller graph for this function:

◆ GetID()

int32_t C4GraphicsOverlay::GetID ( ) const
inline

Definition at line 233 of file C4DefGraphics.h.

233 { return iID; }

References iID.

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

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; }

References OverlayObj.

◆ GetTransform()

C4DrawTransform* C4GraphicsOverlay::GetTransform ( )
inline

Definition at line 231 of file C4DefGraphics.h.

231 { return &Transform; }

References Transform.

◆ IsPicture()

bool C4GraphicsOverlay::IsPicture ( )
inline

Definition at line 238 of file C4DefGraphics.h.

238 { return eMode == MODE_Picture; }

References eMode, and MODE_Picture.

Referenced by Draw(), and DrawPicture().

Here is the caller graph for this function:

◆ IsValid()

bool C4GraphicsOverlay::IsValid ( const C4Object pForObj) const

Definition at line 813 of file C4DefGraphics.cpp.

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 }
GraphicsType Type
Definition: C4DefGraphics.h:48
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
int32_t Status
Definition: C4PropList.h:173

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.

Here is the call graph for this function:

◆ operator==()

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

Definition at line 1103 of file C4DefGraphics.cpp.

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

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

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.

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 }
const unsigned int C4MaxName
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152

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

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

Here is the call graph for this function:
Here is the caller 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)

References MODE_Action, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_Base, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_ExtraGraphics, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_IngamePicture, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_Object, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_ObjectPicture, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_Picture, and Set().

Here is the call graph for this function:

◆ 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); }

References MODE_Rank, and Set().

Here is the call graph for this function:

◆ SetBlitMode()

void C4GraphicsOverlay::SetBlitMode ( uint32_t  dwToMode)
inline

Definition at line 251 of file C4DefGraphics.h.

251 { dwBlitMode = dwToMode; }

References dwBlitMode.

◆ SetClrModulation()

void C4GraphicsOverlay::SetClrModulation ( uint32_t  dwToMod)
inline

Definition at line 248 of file C4DefGraphics.h.

248 { dwClrModulation = dwToMod; }

References dwClrModulation.

◆ SetID()

void C4GraphicsOverlay::SetID ( int32_t  aID)
inline

Definition at line 234 of file C4DefGraphics.h.

234 { iID = aID; }

References iID.

Referenced by C4Object::GetGraphicsOverlay().

Here is the caller graph for this function:

◆ SetNext()

void C4GraphicsOverlay::SetNext ( C4GraphicsOverlay paNext)
inline

Definition at line 237 of file C4DefGraphics.h.

237 { pNext = paNext; }

References pNext.

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

Here is the caller graph for this function:

◆ SetPhase()

void C4GraphicsOverlay::SetPhase ( int32_t  iToPhase)

◆ UpdateFacet()

void C4GraphicsOverlay::UpdateFacet ( )
protected

Definition at line 708 of file C4DefGraphics.cpp.

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 }
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
C4Fixed ftofix(float x)
Definition: C4Real.h:258
@ P_Wdt
@ P_Y
@ P_Length
@ P_Hgt
@ P_X
@ P_Animation
@ P_ActMap
C4Surface * GetBitmap(DWORD dwClr=0)
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:855
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:726
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:744
StdStrBuf GetData() const
Definition: C4StringTable.h:50
C4String * RegString(StdStrBuf String)
void Default()
Definition: C4Facet.h:179
C4PropList * getPropList() const
Definition: C4Value.h:116
float Length
Definition: StdMesh.h:98
AnimationNode * PlayAnimation(const StdStrBuf &animation_name, int slot, AnimationNode *sibling, ValueProvider *position, ValueProvider *weight, bool stop_previous_animation)
Definition: StdMesh.cpp:1167

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().

Here is the call graph for this function:
Here is the caller 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 C4GraphicsOverlay(), CompileFunc(), operator==(), Set(), and UpdateFacet().

◆ dwBlitMode

uint32_t C4GraphicsOverlay::dwBlitMode {0}
protected

Definition at line 188 of file C4DefGraphics.h.

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

◆ dwClrModulation

uint32_t C4GraphicsOverlay::dwClrModulation {0xffffff}
protected

◆ eMode

Mode C4GraphicsOverlay::eMode {MODE_None}
protected

Definition at line 182 of file C4DefGraphics.h.

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

◆ fctBlit

C4TargetFacet C4GraphicsOverlay::fctBlit
protected

Definition at line 186 of file C4DefGraphics.h.

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

◆ fZoomToShape

bool C4GraphicsOverlay::fZoomToShape {false}
protected

Definition at line 193 of file C4DefGraphics.h.

Referenced by Draw(), and UpdateFacet().

◆ iID

int32_t C4GraphicsOverlay::iID {0}
protected

Definition at line 195 of file C4DefGraphics.h.

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

◆ iPhase

int32_t C4GraphicsOverlay::iPhase {0}
protected

Definition at line 192 of file C4DefGraphics.h.

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

◆ OverlayObj

C4ObjectPtr C4GraphicsOverlay::OverlayObj
protected

◆ pMeshInstance

StdMeshInstance* C4GraphicsOverlay::pMeshInstance {nullptr}
protected

Definition at line 187 of file C4DefGraphics.h.

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

◆ pNext

C4GraphicsOverlay* C4GraphicsOverlay::pNext {nullptr}
protected

Definition at line 197 of file C4DefGraphics.h.

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

◆ pSourceGfx

C4DefGraphics* C4GraphicsOverlay::pSourceGfx {nullptr}
protected

Definition at line 184 of file C4DefGraphics.h.

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

◆ Transform

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: