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

#include <C4GameMessage.h>

Collaboration diagram for C4GameMessageList:
[legend]

Public Member Functions

 C4GameMessageList ()
 
 ~C4GameMessageList ()
 
void Default ()
 
void Clear ()
 
void Execute ()
 
void Draw (C4TargetFacet &gui_cgo, C4TargetFacet &cgo, int32_t iPlayer)
 
void ClearPlayers (int32_t iPlayer, int32_t dwPositioningFlags)
 
void ClearPointers (C4Object *pObj)
 
void UpdateDef (C4ID idUpdDef)
 
bool New (int32_t iType, const StdStrBuf &Text, C4Object *pTarget, int32_t iPlayer, int32_t iX=-1, int32_t iY=-1, uint32_t dwClr=0xffFFFFFF, C4ID idDecoID=C4ID::None, C4PropList *pSrc=nullptr, uint32_t dwFlags=0u, int32_t width=0)
 
bool New (int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID=C4ID::None, C4PropList *pSrc=nullptr, uint32_t dwFlags=0u, int32_t width=0)
 
bool Append (int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t bCol, bool fNoDuplicates=false)
 

Protected Attributes

C4GameMessageFirst
 

Detailed Description

Definition at line 82 of file C4GameMessage.h.

Constructor & Destructor Documentation

C4GameMessageList::C4GameMessageList ( )

Definition at line 314 of file C4GameMessage.cpp.

References Default().

315 {
316  Default();
317 }

Here is the call graph for this function:

C4GameMessageList::~C4GameMessageList ( )

Definition at line 319 of file C4GameMessage.cpp.

References Clear().

320 {
321  Clear();
322 }

Here is the call graph for this function:

Member Function Documentation

bool C4GameMessageList::Append ( int32_t  iType,
const char *  szText,
C4Object pTarget,
int32_t  iPlayer,
int32_t  iX,
int32_t  iY,
uint32_t  bCol,
bool  fNoDuplicates = false 
)

Definition at line 397 of file C4GameMessage.cpp.

References C4GameMessage::Append(), C4GM_Global, C4GM_GlobalPlayer, C4GM_Target, First, Messages, New(), C4GameMessage::Next, C4GameMessage::Player, and C4GameMessage::Target.

Referenced by C4Command::Fail().

398 {
399  C4GameMessage *cmsg = nullptr;
400  if (iType == C4GM_Target)
401  {
402  for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
403  if (pTarget == cmsg->Target)
404  break;
405  }
406  if (iType == C4GM_Global || iType == C4GM_GlobalPlayer)
407  {
408  for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
409  if (iPlayer == cmsg->Player)
410  break;
411  }
412  if (!cmsg || pTarget!=cmsg->Target)
413  {
414  New(iType, szText, pTarget, iPlayer, iX, iY, bCol);
415  }
416  else
417  {
418  cmsg->Append(szText, fNoDuplicates);
419  }
420  return true;
421 }
int32_t Player
Definition: C4GameMessage.h:61
const int32_t C4GM_GlobalPlayer
Definition: C4GameMessage.h:30
const int32_t C4GM_Target
Definition: C4GameMessage.h:31
void Append(const char *szText, bool fNoDuplicates=false)
const int32_t C4GM_Global
Definition: C4GameMessage.h:29
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65
C4GameMessageList Messages
C4Object * Target
Definition: C4GameMessage.h:63
bool New(int32_t iType, const StdStrBuf &Text, C4Object *pTarget, int32_t iPlayer, int32_t iX=-1, int32_t iY=-1, uint32_t dwClr=0xffFFFFFF, C4ID idDecoID=C4ID::None, C4PropList *pSrc=nullptr, uint32_t dwFlags=0u, int32_t width=0)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameMessageList::Clear ( )

Definition at line 342 of file C4GameMessage.cpp.

References First, and C4GameMessage::Next.

Referenced by C4Game::Clear(), and ~C4GameMessageList().

343 {
344  C4GameMessage *cmsg,*next;
345  for (cmsg=First; cmsg; cmsg=next)
346  {
347  next=cmsg->Next;
348  delete cmsg;
349  }
350  First=nullptr;
351 }
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65

Here is the caller graph for this function:

void C4GameMessageList::ClearPlayers ( int32_t  iPlayer,
int32_t  dwPositioningFlags 
)

Definition at line 423 of file C4GameMessage.cpp.

References C4GM_Global, C4GM_GlobalPlayer, First, C4GameMessage::GetPositioningFlags(), C4GameMessage::Next, C4GameMessage::Player, and C4GameMessage::Type.

Referenced by New().

424 {
425  C4GameMessage *cmsg,*next,*prev=nullptr;
426  for (cmsg=First; cmsg; cmsg=next)
427  {
428  next=cmsg->Next;
429  if ( (cmsg->Type == C4GM_Global || cmsg->Type == C4GM_GlobalPlayer) && cmsg->Player==iPlayer && cmsg->GetPositioningFlags() == dwPositioningFlags)
430  { delete cmsg; if (prev) prev->Next=next; else First=next; }
431  else
432  prev=cmsg;
433  }
434 }
int32_t Player
Definition: C4GameMessage.h:61
const int32_t C4GM_GlobalPlayer
Definition: C4GameMessage.h:30
int32_t GetPositioningFlags() const
Definition: C4GameMessage.h:79
const int32_t C4GM_Global
Definition: C4GameMessage.h:29
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameMessageList::ClearPointers ( C4Object pObj)

Definition at line 329 of file C4GameMessage.cpp.

References First, C4GameMessage::Next, and C4GameMessage::Target.

Referenced by C4Game::ClearPointers(), and New().

330 {
331  C4GameMessage *cmsg,*next,*prev=nullptr;
332  for (cmsg=First; cmsg; cmsg=next)
333  {
334  next=cmsg->Next;
335  if (cmsg->Target==pObj)
336  { delete cmsg; if (prev) prev->Next=next; else First=next; }
337  else
338  prev=cmsg;
339  }
340 }
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65
C4Object * Target
Definition: C4GameMessage.h:63

Here is the caller graph for this function:

void C4GameMessageList::Default ( )

Definition at line 324 of file C4GameMessage.cpp.

References First.

Referenced by C4GameMessageList(), and C4Game::Default().

325 {
326  First=nullptr;
327 }
C4GameMessage * First
Definition: C4GameMessage.h:88

Here is the caller graph for this function:

void C4GameMessageList::Draw ( C4TargetFacet gui_cgo,
C4TargetFacet cgo,
int32_t  iPlayer 
)

Definition at line 442 of file C4GameMessage.cpp.

References C4D_Foreground, C4GM_Global, C4GM_GlobalPlayer, C4Object::Category, C4GameMessage::Draw(), First, C4GameMessage::Next, C4GameMessage::Target, and C4GameMessage::Type.

Referenced by C4Viewport::Draw().

443 {
444  C4GameMessage *cmsg;
445  for (cmsg=First; cmsg; cmsg=cmsg->Next)
446  {
447  if ((cmsg->Target && (cmsg->Target->Category & C4D_Foreground)) || cmsg->Type == C4GM_Global || cmsg->Type == C4GM_GlobalPlayer)
448  cmsg->Draw(gui_cgo,iPlayer);
449  else
450  cmsg->Draw(cgo,iPlayer);
451  }
452 }
const int32_t C4GM_GlobalPlayer
Definition: C4GameMessage.h:30
int32_t Category
Definition: C4Object.h:113
const int32_t C4GM_Global
Definition: C4GameMessage.h:29
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65
void Draw(C4TargetFacet &cgo, int32_t iPlayer)
C4Object * Target
Definition: C4GameMessage.h:63
const int32_t C4D_Foreground
Definition: C4Def.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameMessageList::Execute ( )

Definition at line 353 of file C4GameMessage.cpp.

References C4GameMessage::Execute(), First, and C4GameMessage::Next.

Referenced by C4Game::Execute().

354 {
355  C4GameMessage *cmsg,*next,*prev=nullptr;
356  for (cmsg=First; cmsg; cmsg=next)
357  {
358  next=cmsg->Next;
359  if (!cmsg->Execute())
360  { delete cmsg; if (prev) prev->Next=next; else First=next; }
361  else
362  prev=cmsg;
363  }
364 }
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GameMessageList::New ( int32_t  iType,
const StdStrBuf Text,
C4Object pTarget,
int32_t  iPlayer,
int32_t  iX = -1,
int32_t  iY = -1,
uint32_t  dwClr = 0xffFFFFFF,
C4ID  idDecoID = C4ID::None,
C4PropList pSrc = nullptr,
uint32_t  dwFlags = 0u,
int32_t  width = 0 
)

Definition at line 371 of file C4GameMessage.cpp.

References C4GM_Global, C4GM_GlobalPlayer, C4GM_Multiple, C4GM_PositioningFlags, ClearPlayers(), ClearPointers(), First, StdStrBuf::getLength(), C4GameMessage::Init(), C4GameMessage::Next, and C4PropList::Status.

Referenced by Append(), GameMsgObject(), GameMsgObjectDw(), GameMsgObjectError(), GameMsgObjectPlayer(), and New().

372 {
373  if (!(dwFlags & C4GM_Multiple))
374  {
375  // Clear messages with same target
376  if (pTarget) ClearPointers(pTarget);
377 
378  // Clear other global messages for the given player
379  if (iType == C4GM_Global || iType == C4GM_GlobalPlayer) ClearPlayers(iPlayer, dwFlags & C4GM_PositioningFlags);
380  }
381 
382  // Object deleted?
383  if (pTarget && !pTarget->Status) return false;
384 
385  // Empty message? (only deleting old message)
386  if (!sText.getLength()) return true;
387 
388  // Add new message
389  C4GameMessage *msgNew = new C4GameMessage;
390  msgNew->Init(iType, sText,pTarget,iPlayer,iX,iY,dwClr, idDecoID, pSrc, dwFlags, width);
391  msgNew->Next=First;
392  First=msgNew;
393 
394  return true;
395 }
void ClearPointers(C4Object *pObj)
const int32_t C4GM_Multiple
Definition: C4GameMessage.h:36
const int32_t C4GM_PositioningFlags
Definition: C4GameMessage.h:48
const int32_t C4GM_GlobalPlayer
Definition: C4GameMessage.h:30
int32_t Status
Definition: C4PropList.h:170
void Init(int32_t iType, const StdStrBuf &Text, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwCol, C4ID idDecoID, C4PropList *pSrc, uint32_t dwFlags, int width)
void ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags)
const int32_t C4GM_Global
Definition: C4GameMessage.h:29
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GameMessageList::New ( int32_t  iType,
const char *  szText,
C4Object pTarget,
int32_t  iPlayer,
int32_t  iX,
int32_t  iY,
uint32_t  dwClr,
C4ID  idDecoID = C4ID::None,
C4PropList pSrc = nullptr,
uint32_t  dwFlags = 0u,
int32_t  width = 0 
)

Definition at line 366 of file C4GameMessage.cpp.

References New().

367 {
368  return New(iType, StdStrBuf(szText), pTarget, iPlayer, iX, iY, dwClr, idDecoID, pSrc, dwFlags, width);
369 }
bool New(int32_t iType, const StdStrBuf &Text, C4Object *pTarget, int32_t iPlayer, int32_t iX=-1, int32_t iY=-1, uint32_t dwClr=0xffFFFFFF, C4ID idDecoID=C4ID::None, C4PropList *pSrc=nullptr, uint32_t dwFlags=0u, int32_t width=0)

Here is the call graph for this function:

void C4GameMessageList::UpdateDef ( C4ID  idUpdDef)

Definition at line 436 of file C4GameMessage.cpp.

References First, C4GameMessage::Next, and C4GameMessage::UpdateDef().

Referenced by C4Game::ReloadDef().

437 {
438  C4GameMessage *cmsg;
439  for (cmsg=First; cmsg; cmsg=cmsg->Next) cmsg->UpdateDef(idUpdDef);
440 }
void UpdateDef(C4ID idUpdDef)
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

C4GameMessage* C4GameMessageList::First
protected

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