44#include < sstream>
55#include < iomanip>
66
7- BAKKESMOD_PLUGIN (StreamGraphicsGSI, " StreamGraphicsGSI" , " 1.2 .0" , PLUGINTYPE_THREADED)
7+ BAKKESMOD_PLUGIN (StreamGraphicsGSI, " StreamGraphicsGSI" , " 1.3 .0" , PLUGINTYPE_THREADED)
88
99using placeholders::_1;
1010
11+ const float COLOR_DARKEN = 0.75 ;
12+
1113#pragma region Plugin Methods
1214void StreamGraphicsGSI::onLoad ()
1315{
@@ -127,6 +129,14 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {
127129 GameState.Match .Teams [i].Red = asd.R ;
128130 GameState.Match .Teams [i].Green = asd.G ;
129131 GameState.Match .Teams [i].Blue = asd.B ;
132+
133+ std::stringstream team_hex;
134+ team_hex << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * 0xff ) << 16 | (int )(asd.G * 0xff ) << 8 | (int )(asd.B * 0xff ));
135+ GameState.Match .Teams [i].ColorHex = team_hex.str ();
136+
137+ std::stringstream team_hex_dark;
138+ team_hex_dark << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * COLOR_DARKEN * 0xff ) << 16 | (int )(asd.G * COLOR_DARKEN * 0xff ) << 8 | (int )(asd.B * COLOR_DARKEN * 0xff ) & 0xff );
139+ GameState.Match .Teams [i].ColorDarkHex = team_hex_dark.str ();
130140 }
131141
132142
@@ -149,10 +159,24 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {
149159 GameState.Player .Name = local.GetPlayerName ().ToString ();
150160 GameState.Player .Ping = (int )local.GetExactPing ();
151161
152- if (!local.GetTeam ().IsNull ())
162+ if (!local.GetTeam ().IsNull () && (local. GetTeam (). GetTeamIndex () == 0 || local. GetTeam (). GetTeamIndex () == 1 )) {
153163 GameState.Player .Team = local.GetTeam ().GetTeamIndex ();
154- else
155- GameState.Player .Team = 0 ;
164+
165+ LinearColor asd = wrapper.GetTeams ().Get (local.GetTeam ().GetTeamIndex ()).GetFontColor ();
166+
167+ std::stringstream team_hex;
168+ team_hex << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * 0xff ) << 16 | (int )(asd.G * 0xff ) << 8 | (int )(asd.B * 0xff ));
169+ GameState.Player .ColorHex = team_hex.str ();
170+
171+ std::stringstream team_hex_dark;
172+ team_hex_dark << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * COLOR_DARKEN * 0xff ) << 16 | (int )(asd.G * COLOR_DARKEN * 0xff ) << 8 | (int )(asd.B * COLOR_DARKEN * 0xff ) & 0xff );
173+ GameState.Player .ColorDarkHex = team_hex_dark.str ();
174+ }
175+ else {
176+ GameState.Player .Team = -1 ;
177+ GameState.Player .ColorHex = " #1A1A1A" ;
178+ GameState.Player .ColorDarkHex = " #000000" ;
179+ }
156180
157181 if (!local.GetCar ().IsNull () && !local.GetCar ().GetBoostComponent ().IsNull ())
158182 GameState.Player .CurrentBoostAmount = local.GetCar ().GetBoostComponent ().GetCurrentBoostAmount ();
@@ -164,6 +188,8 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {
164188 GameState.Player .Team = 0 ;
165189 GameState.Player .Name = " " ;
166190 GameState.Player .Ping = 0 ;
191+ GameState.Player .ColorHex = " #1A1A1A" ;
192+ GameState.Player .ColorDarkHex = " #000000" ;
167193
168194 GameState.Player .Score = 0 ;
169195 GameState.Player .Goals = 0 ;
@@ -213,6 +239,22 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {
213239 boost = spec_player.GetCar ().GetBoostComponent ().GetCurrentBoostAmount ();
214240 }
215241
242+ if (!spec_player.GetTeam ().IsNull () && (team == 0 || team == 1 )) {
243+ LinearColor asd = wrapper.GetTeams ().Get (team).GetFontColor ();
244+
245+ std::stringstream team_hex;
246+ team_hex << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * 0xff ) << 16 | (int )(asd.G * 0xff ) << 8 | (int )(asd.B * 0xff ));
247+ GameState.CurrentSpec .ColorHex = team_hex.str ();
248+
249+ std::stringstream team_hex_dark;
250+ team_hex_dark << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * COLOR_DARKEN * 0xff ) << 16 | (int )(asd.G * COLOR_DARKEN * 0xff ) << 8 | (int )(asd.B * COLOR_DARKEN * 0xff ) & 0xff );
251+ GameState.CurrentSpec .ColorDarkHex = team_hex_dark.str ();
252+ }
253+ else {
254+ GameState.CurrentSpec .ColorHex = " #1A1A1A" ;
255+ GameState.CurrentSpec .ColorDarkHex = " #000000" ;
256+ }
257+
216258 GameState.CurrentSpec .Team = team;
217259 GameState.CurrentSpec .Name = name;
218260 GameState.CurrentSpec .Ping = ping;
@@ -236,6 +278,8 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {
236278 GameState.CurrentSpec .Team = -1 ;
237279 GameState.CurrentSpec .Name = " " ;
238280 GameState.CurrentSpec .Ping = 0 ;
281+ GameState.CurrentSpec .ColorHex = " #1A1A1A" ;
282+ GameState.CurrentSpec .ColorDarkHex = " #000000" ;
239283
240284 GameState.CurrentSpec .Score = 0 ;
241285 GameState.CurrentSpec .Goals = 0 ;
@@ -306,6 +350,22 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {
306350
307351 GameState.Match .Teams [team].TeamBoost += boost;
308352 GameState.Match .Teams [team].PlayerCount += 1 ;
353+
354+ if (!player.GetTeam ().IsNull ()) {
355+ LinearColor asd = wrapper.GetTeams ().Get (team).GetFontColor ();
356+
357+ std::stringstream team_hex;
358+ team_hex << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * 0xff ) << 16 | (int )(asd.G * 0xff ) << 8 | (int )(asd.B * 0xff ));
359+ GameState.SpecPlayers [specSlot - 1 ].ColorHex = team_hex.str ();
360+
361+ std::stringstream team_hex_dark;
362+ team_hex_dark << " #" << std::setw (6 ) << std::setfill (' 0' ) << std::hex << ((int )(asd.R * COLOR_DARKEN * 0xff ) << 16 | (int )(asd.G * COLOR_DARKEN * 0xff ) << 8 | (int )(asd.B * COLOR_DARKEN * 0xff ) & 0xff );
363+ GameState.SpecPlayers [specSlot - 1 ].ColorDarkHex = team_hex_dark.str ();
364+ }
365+ else {
366+ GameState.SpecPlayers [specSlot - 1 ].ColorHex = " #1A1A1A" ;
367+ GameState.SpecPlayers [specSlot - 1 ].ColorHex = " #000000" ;
368+ }
309369 }
310370 }
311371}
@@ -328,6 +388,8 @@ void StreamGraphicsGSI::ResetStates()
328388 GameState.Match .Teams [0 ].Blue = 0 ;
329389 GameState.Match .Teams [0 ].TeamBoost = 0.0 ;
330390 GameState.Match .Teams [0 ].Name = " " ;
391+ GameState.Match .Teams [0 ].ColorHex = " #1A1A1A" ;
392+ GameState.Match .Teams [1 ].ColorDarkHex = " #000000" ;
331393
332394 GameState.Match .Teams [1 ].Index = 1 ;
333395 GameState.Match .Teams [1 ].PlayerCount = 0 ;
@@ -337,9 +399,14 @@ void StreamGraphicsGSI::ResetStates()
337399 GameState.Match .Teams [1 ].Blue = 0 ;
338400 GameState.Match .Teams [1 ].TeamBoost = 0.0 ;
339401 GameState.Match .Teams [1 ].Name = " " ;
402+ GameState.Match .Teams [1 ].ColorHex = " #1A1A1A" ;
403+ GameState.Match .Teams [1 ].ColorDarkHex = " #000000" ;
340404
341405 GameState.Player .Team = -1 ;
342406 GameState.Player .Name = " " ;
407+ GameState.Player .Ping = 0 ;
408+ GameState.Player .ColorHex = " #1A1A1A" ;
409+ GameState.Player .ColorDarkHex = " #000000" ;
343410
344411 GameState.Player .Assists = 0 ;
345412 GameState.Player .Goals = 0 ;
@@ -358,6 +425,8 @@ void StreamGraphicsGSI::ResetStates()
358425 GameState.CurrentSpec .Team = -1 ;
359426 GameState.CurrentSpec .Name = " " ;
360427 GameState.CurrentSpec .Ping = 0 ;
428+ GameState.CurrentSpec .ColorHex = " #1A1A1A" ;
429+ GameState.CurrentSpec .ColorDarkHex = " #000000" ;
361430
362431 GameState.CurrentSpec .Score = 0 ;
363432 GameState.CurrentSpec .Goals = 0 ;
@@ -379,6 +448,8 @@ void StreamGraphicsGSI::ResetStates()
379448 GameState.SpecPlayers [i].Team = -1 ;
380449 GameState.SpecPlayers [i].Name = " " ;
381450 GameState.SpecPlayers [i].Ping = 0 ;
451+ GameState.SpecPlayers [i].ColorHex = " #1A1A1A" ;
452+ GameState.SpecPlayers [i].ColorDarkHex = " #000000" ;
382453
383454 GameState.SpecPlayers [i].Assists = 0 ;
384455 GameState.SpecPlayers [i].Goals = 0 ;
0 commit comments