ddnet/src/game/client/components/broadcast.cpp

39 lines
1 KiB
C++
Raw Normal View History

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>
2010-05-29 07:25:38 +00:00
#include <game/client/gameclient.h>
2010-05-29 07:25:38 +00:00
#include "broadcast.h"
2010-05-29 07:25:38 +00:00
void CBroadcast::OnReset()
{
2010-05-29 07:25:38 +00:00
m_BroadcastTime = 0;
}
2010-05-29 07:25:38 +00:00
void CBroadcast::OnRender()
{
2009-10-27 14:38:53 +00:00
Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300);
2010-05-29 07:25:38 +00:00
if(time_get() < m_BroadcastTime)
{
2010-05-29 07:25:38 +00:00
float w = TextRender()->TextWidth(0, 14, m_aBroadcastText, -1);
TextRender()->Text(0, 150*Graphics()->ScreenAspect()-w/2, 35, 14, m_aBroadcastText, -1);
}
}
2010-05-29 07:25:38 +00:00
void CBroadcast::OnMessage(int MsgType, void *pRawMsg)
{
2010-05-29 07:25:38 +00:00
if(MsgType == NETMSGTYPE_SV_BROADCAST)
{
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));
m_BroadcastTime = time_get()+time_freq()*10;
}
}