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 311 of file C4GameMessage.cpp.

References Default().

312 {
313  Default();
314 }

Here is the call graph for this function:

C4GameMessageList::~C4GameMessageList ( )

Definition at line 316 of file C4GameMessage.cpp.

References Clear().

317 {
318  Clear();
319 }

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

395 {
396  C4GameMessage *cmsg = nullptr;
397  if (iType == C4GM_Target)
398  {
399  for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
400  if (pTarget == cmsg->Target)
401  break;
402  }
403  if (iType == C4GM_Global || iType == C4GM_GlobalPlayer)
404  {
405  for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
406  if (iPlayer == cmsg->Player)
407  break;
408  }
409  if (!cmsg || pTarget!=cmsg->Target)
410  {
411  New(iType, szText, pTarget, iPlayer, iX, iY, bCol);
412  }
413  else
414  {
415  cmsg->Append(szText, fNoDuplicates);
416  }
417  return true;
418 }
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 339 of file C4GameMessage.cpp.

References First, and C4GameMessage::Next.

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

340 {
341  C4GameMessage *cmsg,*next;
342  for (cmsg=First; cmsg; cmsg=next)
343  {
344  next=cmsg->Next;
345  delete cmsg;
346  }
347  First=nullptr;
348 }
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 420 of file C4GameMessage.cpp.

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

Referenced by New().

421 {
422  C4GameMessage *cmsg,*next,*prev=nullptr;
423  for (cmsg=First; cmsg; cmsg=next)
424  {
425  next=cmsg->Next;
426  if ( (cmsg->Type == C4GM_Global || cmsg->Type == C4GM_GlobalPlayer) && cmsg->Player==iPlayer && cmsg->GetPositioningFlags() == dwPositioningFlags)
427  { delete cmsg; if (prev) prev->Next=next; else First=next; }
428  else
429  prev=cmsg;
430  }
431 }
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 326 of file C4GameMessage.cpp.

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

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

327 {
328  C4GameMessage *cmsg,*next,*prev=nullptr;
329  for (cmsg=First; cmsg; cmsg=next)
330  {
331  next=cmsg->Next;
332  if (cmsg->Target==pObj)
333  { delete cmsg; if (prev) prev->Next=next; else First=next; }
334  else
335  prev=cmsg;
336  }
337 }
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 321 of file C4GameMessage.cpp.

References First.

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

322 {
323  First=nullptr;
324 }
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 439 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().

440 {
441  C4GameMessage *cmsg;
442  for (cmsg=First; cmsg; cmsg=cmsg->Next)
443  {
444  if ((cmsg->Target && (cmsg->Target->Category & C4D_Foreground)) || cmsg->Type == C4GM_Global || cmsg->Type == C4GM_GlobalPlayer)
445  cmsg->Draw(gui_cgo,iPlayer);
446  else
447  cmsg->Draw(cgo,iPlayer);
448  }
449 }
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:53

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameMessageList::Execute ( )

Definition at line 350 of file C4GameMessage.cpp.

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

Referenced by C4Game::Execute().

351 {
352  C4GameMessage *cmsg,*next,*prev=nullptr;
353  for (cmsg=First; cmsg; cmsg=next)
354  {
355  next=cmsg->Next;
356  if (!cmsg->Execute())
357  { delete cmsg; if (prev) prev->Next=next; else First=next; }
358  else
359  prev=cmsg;
360  }
361 }
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 368 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().

369 {
370  if (!(dwFlags & C4GM_Multiple))
371  {
372  // Clear messages with same target
373  if (pTarget) ClearPointers(pTarget);
374 
375  // Clear other global messages for the given player
376  if (iType == C4GM_Global || iType == C4GM_GlobalPlayer) ClearPlayers(iPlayer, dwFlags & C4GM_PositioningFlags);
377  }
378 
379  // Object deleted?
380  if (pTarget && !pTarget->Status) return false;
381 
382  // Empty message? (only deleting old message)
383  if (!sText.getLength()) return true;
384 
385  // Add new message
386  C4GameMessage *msgNew = new C4GameMessage;
387  msgNew->Init(iType, sText,pTarget,iPlayer,iX,iY,dwClr, idDecoID, pSrc, dwFlags, width);
388  msgNew->Next=First;
389  First=msgNew;
390 
391  return true;
392 }
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:168
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 363 of file C4GameMessage.cpp.

References New().

364 {
365  return New(iType, StdStrBuf(szText), pTarget, iPlayer, iX, iY, dwClr, idDecoID, pSrc, dwFlags, width);
366 }
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 433 of file C4GameMessage.cpp.

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

Referenced by C4Game::ReloadDef().

434 {
435  C4GameMessage *cmsg;
436  for (cmsg=First; cmsg; cmsg=cmsg->Next) cmsg->UpdateDef(idUpdDef);
437 }
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: