OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GameMessage.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Text messages drawn inside the viewport */
19 
20 #ifndef INC_C4GameMessage
21 #define INC_C4GameMessage
22 
23 #include "lib/StdColors.h"
24 #include "script/C4Value.h"
25 
26 const int32_t C4GM_MaxText = 256,
28 
29 const int32_t C4GM_Global = 1,
33 
34 const int32_t C4GM_NoBreak = 1<<0,
35  C4GM_Bottom = 1<<1, // message placed at bottom of screen
37  C4GM_Top = 1<<3,
38  C4GM_Left = 1<<4,
39  C4GM_Right = 1<<5,
40  C4GM_HCenter = 1<<6,
41  C4GM_VCenter = 1<<7,
42  C4GM_DropSpeech = 1<<8, // cut any text after '$'
43  C4GM_WidthRel = 1<<9,
44  C4GM_XRel = 1<<10,
45  C4GM_YRel = 1<<11,
46  C4GM_Zoom = 1<<12;
47 
49 
51 {
52  friend class C4GameMessageList;
53 public:
54  void Draw(C4TargetFacet &cgo, int32_t iPlayer);
55  C4GameMessage();
57 protected:
58  int32_t X, Y, Wdt, Hgt;
59  int32_t Delay;
61  int32_t Player;
62  int32_t Type;
67  C4PropList *PictureDef; // can be definition, object or prop list with Source and Name properties
68  C4Value PictureDefVal; // C4Value holding PictureDef to prevent deletion
70  uint32_t dwFlags;
71 protected:
72  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);
73  void Append(const char *szText, bool fNoDuplicates = false);
74  bool Execute();
75  const char *WordWrap(int32_t iMaxWidth);
76  void UpdateDef(C4ID idUpdDef);
77 
78 public:
79  int32_t GetPositioningFlags() const { return dwFlags & C4GM_PositioningFlags; }
80 };
81 
83 {
84 public:
87 protected:
89 public:
90  void Default();
91  void Clear();
92  void Execute();
93  void Draw(C4TargetFacet &gui_cgo, C4TargetFacet &cgo, int32_t iPlayer);
94  void ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags);
95  void ClearPointers(C4Object *pObj);
96  void UpdateDef(C4ID idUpdDef); // called after reloaddef
97  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);
98  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);
99  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);
100 };
101 
103 
104 inline void GameMsgObject(const char *szText, C4Object *pTarget)
105 {
106  ::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,C4RGB(0xff, 0xff, 0xff));
107 }
108 
109 inline void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer)
110 {
111  ::Messages.New(C4GM_TargetPlayer,szText,pTarget,iPlayer,0,0, C4RGB(0xff, 0xff, 0xff));
112 }
113 
114 void GameMsgObjectError(const char *szText, C4Object *pTarget, bool Red = true);
115 
116 inline void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr)
117 {
118  ::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,dwClr);
119 }
120 #endif
void UpdateDef(C4ID idUpdDef)
void ClearPointers(C4Object *pObj)
const int32_t C4GM_Multiple
Definition: C4GameMessage.h:36
void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer)
const int32_t C4GM_PositioningFlags
Definition: C4GameMessage.h:48
const int32_t C4GM_DropSpeech
Definition: C4GameMessage.h:42
C4GameMessageList Messages
const int32_t C4GM_Top
Definition: C4GameMessage.h:37
const int32_t C4GM_YRel
Definition: C4GameMessage.h:45
const int32_t C4GM_XRel
Definition: C4GameMessage.h:44
const int32_t C4GM_TargetPlayer
Definition: C4GameMessage.h:32
StdCopyStrBuf Text
Definition: C4GameMessage.h:64
const int32_t C4GM_NoBreak
Definition: C4GameMessage.h:34
const int32_t C4GM_Bottom
Definition: C4GameMessage.h:35
const int32_t C4GM_Zoom
Definition: C4GameMessage.h:46
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)
const int32_t C4GM_MinDelay
Definition: C4GameMessage.h:27
int32_t Player
Definition: C4GameMessage.h:61
C4GUI::FrameDecoration * pFrameDeco
Definition: C4GameMessage.h:69
const int32_t C4GM_Right
Definition: C4GameMessage.h:39
static const C4ID None
Definition: C4Id.h:42
const int32_t C4GM_VCenter
Definition: C4GameMessage.h:41
const int NO_OWNER
Definition: C4Constants.h:138
const int32_t C4GM_GlobalPlayer
Definition: C4GameMessage.h:30
const int32_t C4GM_Target
Definition: C4GameMessage.h:31
#define C4RGB(r, g, b)
Definition: StdColors.h:28
void Append(const char *szText, bool fNoDuplicates=false)
Definition: C4Id.h:28
const char * WordWrap(int32_t iMaxWidth)
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)
int32_t GetPositioningFlags() const
Definition: C4GameMessage.h:79
void ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags)
void UpdateDef(C4ID idUpdDef)
void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr)
const int32_t C4GM_WidthRel
Definition: C4GameMessage.h:43
const int32_t C4GM_Global
Definition: C4GameMessage.h:29
C4Value PictureDefVal
Definition: C4GameMessage.h:68
const int32_t C4GM_MaxText
Definition: C4GameMessage.h:26
C4GameMessage * First
Definition: C4GameMessage.h:88
C4GameMessage * Next
Definition: C4GameMessage.h:65
const int32_t C4GM_HCenter
Definition: C4GameMessage.h:40
void Draw(C4TargetFacet &cgo, int32_t iPlayer)
uint32_t DWORD
const int32_t C4GM_Left
Definition: C4GameMessage.h:38
C4Object * Target
Definition: C4GameMessage.h:63
void GameMsgObjectError(const char *szText, C4Object *pTarget, bool Red=true)
C4PropList * PictureDef
Definition: C4GameMessage.h:67
void GameMsgObject(const char *szText, C4Object *pTarget)
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)
void Draw(C4TargetFacet &gui_cgo, C4TargetFacet &cgo, int32_t iPlayer)
uint32_t dwFlags
Definition: C4GameMessage.h:70