forked from Mirrors/openclonk
131 lines
4.5 KiB
C++
131 lines
4.5 KiB
C++
/*
|
|
* OpenClonk, http://www.openclonk.org
|
|
*
|
|
* Copyright (c) 1998-2000 Matthes Bender
|
|
* Copyright (c) 2001, 2005, 2008 Sven Eberhardt
|
|
* Copyright (c) 2001 Michael Käser
|
|
* Copyright (c) 2004 Günther Brammer
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
*
|
|
* Portions might be copyrighted by other authors who have contributed
|
|
* to OpenClonk.
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
* See isc_license.txt for full license and disclaimer.
|
|
*
|
|
* "Clonk" is a registered trademark of Matthes Bender.
|
|
* See clonk_trademark_license.txt for full license.
|
|
*/
|
|
|
|
/* Text messages drawn inside the viewport */
|
|
|
|
#ifndef INC_C4GameMessage
|
|
#define INC_C4GameMessage
|
|
|
|
#include <C4Surface.h>
|
|
#include <C4Gui.h>
|
|
|
|
const int32_t C4GM_MaxText = 256,
|
|
C4GM_MinDelay = 20;
|
|
|
|
const int32_t C4GM_Global = 1,
|
|
C4GM_GlobalPlayer = 2,
|
|
C4GM_Target = 3,
|
|
C4GM_TargetPlayer = 4;
|
|
|
|
const int32_t C4GM_NoBreak = 1<<0,
|
|
C4GM_Bottom = 1<<1, // message placed at bottom of screen
|
|
C4GM_Multiple= 1<<2,
|
|
C4GM_Top = 1<<3,
|
|
C4GM_Left = 1<<4,
|
|
C4GM_Right = 1<<5,
|
|
C4GM_HCenter = 1<<6,
|
|
C4GM_VCenter = 1<<7,
|
|
C4GM_DropSpeech = 1<<8, // cut any text after '$'
|
|
C4GM_WidthRel = 1<<9,
|
|
C4GM_XRel = 1<<10,
|
|
C4GM_YRel = 1<<11;
|
|
|
|
const int32_t C4GM_PositioningFlags = C4GM_Bottom | C4GM_Top | C4GM_Left | C4GM_Right | C4GM_HCenter | C4GM_VCenter;
|
|
|
|
class C4GameMessage
|
|
{
|
|
friend class C4GameMessageList;
|
|
public:
|
|
void Draw(C4TargetFacet &cgo, int32_t iPlayer, float Zoom);
|
|
C4GameMessage();
|
|
~C4GameMessage();
|
|
protected:
|
|
int32_t X,Y,Wdt;
|
|
int32_t Delay;
|
|
DWORD ColorDw;
|
|
int32_t Player;
|
|
int32_t Type;
|
|
C4Object *Target;
|
|
StdCopyStrBuf Text;
|
|
C4GameMessage *Next;
|
|
C4ID DecoID; StdStrBuf PortraitDef;
|
|
C4GUI::FrameDecoration *pFrameDeco;
|
|
uint32_t dwFlags;
|
|
protected:
|
|
void Init(int32_t iType, const StdStrBuf & Text, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwCol, C4ID idDecoID, const char *szPortraitDef, uint32_t dwFlags, int width);
|
|
void Append(const char *szText, BOOL fNoDuplicates = FALSE);
|
|
BOOL Execute();
|
|
const char *WordWrap(int32_t iMaxWidth);
|
|
void UpdateDef(C4ID idUpdDef);
|
|
|
|
public:
|
|
int32_t GetPositioningFlags() const { return dwFlags & C4GM_PositioningFlags; }
|
|
};
|
|
|
|
class C4GameMessageList
|
|
{
|
|
public:
|
|
C4GameMessageList();
|
|
~C4GameMessageList();
|
|
protected:
|
|
C4GameMessage *First;
|
|
public:
|
|
void Default();
|
|
void Clear();
|
|
void Execute();
|
|
void Draw(C4TargetFacet &cgo, int32_t iPlayer, float Zoom);
|
|
void ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags);
|
|
void ClearPointers(C4Object *pObj);
|
|
void UpdateDef(C4ID idUpdDef); // called after reloaddef
|
|
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, const char *szPortraitDef=NULL, 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, uint8_t bCol);
|
|
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, const char *szPortraitDef=NULL, 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, uint8_t bCol, bool fNoDuplicates = false);
|
|
};
|
|
|
|
extern C4GameMessageList Messages;
|
|
|
|
inline void GameMsgObject(const char *szText, C4Object *pTarget, int32_t iFCol=FWhite)
|
|
{
|
|
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,(uint8_t) iFCol);
|
|
}
|
|
|
|
inline void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iFCol=FWhite)
|
|
{
|
|
::Messages.New(C4GM_TargetPlayer,szText,pTarget,iPlayer,0,0,(uint8_t) iFCol);
|
|
}
|
|
|
|
inline void GameMsgGlobal(const char *szText, int32_t iFCol=FWhite)
|
|
{
|
|
::Messages.New(C4GM_Global,szText,NULL,ANY_OWNER,0,0,(uint8_t) iFCol);
|
|
}
|
|
|
|
inline void GameMsgPlayer(const char *szText, int32_t iPlayer, int32_t iFCol=FWhite)
|
|
{
|
|
::Messages.New(C4GM_GlobalPlayer,szText,NULL,iPlayer,0,0,(uint8_t) iFCol);
|
|
}
|
|
|
|
inline void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr)
|
|
{
|
|
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,dwClr);
|
|
}
|
|
#endif
|