2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/shared/config.h>
|
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/textrender.h>
|
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
#include <game/generated/client_data.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/gameclient.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-01-17 12:46:59 +00:00
|
|
|
#include <game/client/components/motd.h>
|
2011-01-12 00:18:07 +00:00
|
|
|
#include <game/client/components/scoreboard.h>
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "broadcast.h"
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CBroadcast::OnReset()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_BroadcastTime = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CBroadcast::OnRender()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-01-17 12:46:59 +00:00
|
|
|
if(m_pClient->m_pScoreboard->Active() || m_pClient->m_pMotd->IsActive())
|
2011-01-12 00:18:07 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(time_get() < m_BroadcastTime)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-12-16 02:17:16 +00:00
|
|
|
CTextCursor Cursor;
|
|
|
|
TextRender()->SetCursor(&Cursor, m_BroadcastRenderOffset, 40.0f, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
2011-01-09 22:25:07 +00:00
|
|
|
Cursor.m_LineWidth = 300*Graphics()->ScreenAspect()-m_BroadcastRenderOffset;
|
2010-12-16 02:17:16 +00:00
|
|
|
TextRender()->TextEx(&Cursor, m_aBroadcastText, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CBroadcast::OnMessage(int MsgType, void *pRawMsg)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(MsgType == NETMSGTYPE_SV_BROADCAST)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CNetMsg_Sv_Broadcast *pMsg = (CNetMsg_Sv_Broadcast *)pRawMsg;
|
|
|
|
str_copy(m_aBroadcastText, pMsg->m_pMessage, sizeof(m_aBroadcastText));
|
2010-12-16 02:17:16 +00:00
|
|
|
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;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_BroadcastTime = time_get()+time_freq()*10;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|