made broadcast text a bit smaller and cut it off if it's bigger than the screen. Closes #313

This commit is contained in:
oy 2010-12-16 03:17:16 +01:00
parent c6848cd229
commit 54f138f894
2 changed files with 12 additions and 4 deletions

View file

@ -21,8 +21,10 @@ void CBroadcast::OnRender()
if(time_get() < m_BroadcastTime) if(time_get() < m_BroadcastTime)
{ {
float w = TextRender()->TextWidth(0, 14, m_aBroadcastText, -1); CTextCursor Cursor;
TextRender()->Text(0, 150*Graphics()->ScreenAspect()-w/2, 35, 14, m_aBroadcastText, -1); TextRender()->SetCursor(&Cursor, m_BroadcastRenderOffset, 40.0f, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = 300*Graphics()->ScreenAspect()-2*m_BroadcastRenderOffset;
TextRender()->TextEx(&Cursor, m_aBroadcastText, -1);
} }
} }
@ -32,6 +34,11 @@ void CBroadcast::OnMessage(int MsgType, void *pRawMsg)
{ {
CNetMsg_Sv_Broadcast *pMsg = (CNetMsg_Sv_Broadcast *)pRawMsg; CNetMsg_Sv_Broadcast *pMsg = (CNetMsg_Sv_Broadcast *)pRawMsg;
str_copy(m_aBroadcastText, pMsg->m_pMessage, sizeof(m_aBroadcastText)); str_copy(m_aBroadcastText, pMsg->m_pMessage, sizeof(m_aBroadcastText));
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, 12.0f, TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = 300*Graphics()->ScreenAspect();
TextRender()->TextEx(&Cursor, m_aBroadcastText, -1);
m_BroadcastRenderOffset = 150*Graphics()->ScreenAspect()-Cursor.m_X/2;
m_BroadcastTime = time_get()+time_freq()*10; m_BroadcastTime = time_get()+time_freq()*10;
} }
} }

View file

@ -6,11 +6,12 @@
class CBroadcast : public CComponent class CBroadcast : public CComponent
{ {
public:
// broadcasts // broadcasts
char m_aBroadcastText[1024]; char m_aBroadcastText[1024];
int64 m_BroadcastTime; int64 m_BroadcastTime;
float m_BroadcastRenderOffset;
public:
virtual void OnReset(); virtual void OnReset();
virtual void OnRender(); virtual void OnRender();
virtual void OnMessage(int MsgType, void *pRawMsg); virtual void OnMessage(int MsgType, void *pRawMsg);