core/smn_hudtext.cpp
changeset 3743 a98686a77974
parent 3010 8ea042c00c80
child 3855 d8ba5eddf543
     1.1 --- a/core/smn_hudtext.cpp	Mon Jan 07 09:09:14 2013 -0500
     1.2 +++ b/core/smn_hudtext.cpp	Tue Jan 22 21:43:12 2013 -0500
     1.3 @@ -37,6 +37,10 @@
     1.4  #include "HandleSys.h"
     1.5  #include "logic_bridge.h"
     1.6  
     1.7 +#if SOURCE_ENGINE == SE_CSGO
     1.8 +#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
     1.9 +#endif
    1.10 +
    1.11  #define MAX_HUD_CHANNELS		6
    1.12  
    1.13  int g_HudMsgNum = -1;
    1.14 @@ -308,12 +312,39 @@
    1.15  
    1.16  void UTIL_SendHudText(int client, const hud_text_parms &textparms, const char *pMessage)
    1.17  {
    1.18 -	bf_write *bf;
    1.19  	cell_t players[1];
    1.20  
    1.21  	players[0] = client;
    1.22  
    1.23 -	bf = g_UserMsgs.StartMessage(g_HudMsgNum, players, 1, 0);
    1.24 +#if SOURCE_ENGINE == SE_CSGO
    1.25 +	// If or when we need to support multiple games per engine with this, we can switch to reflection
    1.26 +	CCSUsrMsg_HudMsg *msg = (CCSUsrMsg_HudMsg *)g_UserMsgs.StartProtobufMessage(g_HudMsgNum, players, 1, 0);
    1.27 +	msg->set_channel(textparms.channel & 0xFF);
    1.28 +
    1.29 +	CMsgVector2D *pos = msg->mutable_pos();
    1.30 +	pos->set_x(textparms.x);
    1.31 +	pos->set_y(textparms.y);
    1.32 +
    1.33 +	CMsgRGBA *color1 = msg->mutable_clr1();
    1.34 +	color1->set_r(textparms.r1);
    1.35 +	color1->set_g(textparms.g1);
    1.36 +	color1->set_b(textparms.b1);
    1.37 +	color1->set_a(textparms.a1);
    1.38 +
    1.39 +	CMsgRGBA *color2 = msg->mutable_clr2();
    1.40 +	color2->set_r(textparms.r2);
    1.41 +	color2->set_g(textparms.g2);
    1.42 +	color2->set_b(textparms.b2);
    1.43 +	color2->set_a(textparms.a2);
    1.44 +
    1.45 +	msg->set_effect(textparms.effect);
    1.46 +	msg->set_fade_in_time(textparms.fadeinTime);
    1.47 +	msg->set_fade_out_time(textparms.fadeoutTime);
    1.48 +	msg->set_hold_time(textparms.holdTime);
    1.49 +	msg->set_fx_time(textparms.fxTime);
    1.50 +	msg->set_text(pMessage);
    1.51 +#else
    1.52 +	bf_write *bf = g_UserMsgs.StartBitBufMessage(g_HudMsgNum, players, 1, 0);
    1.53  	bf->WriteByte(textparms.channel & 0xFF );
    1.54  	bf->WriteFloat(textparms.x);
    1.55  	bf->WriteFloat(textparms.y);
    1.56 @@ -331,6 +362,7 @@
    1.57  	bf->WriteFloat(textparms.holdTime);
    1.58  	bf->WriteFloat(textparms.fxTime);
    1.59  	bf->WriteString(pMessage);
    1.60 +#endif
    1.61  	g_UserMsgs.EndMessage();
    1.62  }
    1.63