Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit df1ea3c

Browse files
committed
Add hex representation of team color.
1 parent 5b5736a commit df1ea3c

File tree

6 files changed

+89
-5
lines changed

6 files changed

+89
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# StreamGraphicsGSI-RL
22

3-
Version: 1.2.0
3+
Version: 1.3.0
44

55
Orignal coded based on [diogotr7/AuroraGSI-RocketLeague](https://github.com/diogotr7/AuroraGSI-RocketLeague).
66

StreamGraphicsGSI-RL/PlayerNode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ nlohmann::json PlayerNode::GetJson()
77
json_player["team"] = Team;
88
json_player["name"] = Name;
99
json_player["ping"] = Ping;
10+
json_player["color_hex"] = ColorHex;
11+
json_player["color_css"] = "background-color: " + ColorHex + ";";
12+
json_player["color_dark_hex"] = ColorDarkHex;
13+
json_player["color_dark_css"] = "background-color: " + ColorDarkHex + ";";
1014

1115
json_player["score"] = Score;
1216
json_player["goals"] = Goals;

StreamGraphicsGSI-RL/PlayerNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class PlayerNode {
66
int Team = -1;
77
std::string Name = "";
88

9+
std::string ColorHex = "#1A1A1A";
10+
std::string ColorDarkHex = "#000000";
11+
912
int Ping = 0;
1013

1114
int Score = 0;

StreamGraphicsGSI-RL/StreamGraphicsGSI.cpp

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
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

99
using placeholders::_1;
1010

11+
const float COLOR_DARKEN = 0.75;
12+
1113
#pragma region Plugin Methods
1214
void 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;

StreamGraphicsGSI-RL/TeamNode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ nlohmann::json TeamNode::GetJson()
1010
json_team["red"] = Red;
1111
json_team["green"] = Green;
1212
json_team["blue"] = Blue;
13+
json_team["color_hex"] = ColorHex;
14+
json_team["color_css"] = "background-color: " + ColorHex + ";";
15+
json_team["color_dark_hex"] = ColorDarkHex;
16+
json_team["color_dark_css"] = "background-color: " + ColorDarkHex + ";";
1317

1418
json_team["boost"] = TeamBoost;
1519

StreamGraphicsGSI-RL/TeamNode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class TeamNode {
1010
float Red = 0;
1111
float Green = 0;
1212
float Blue = 0;
13+
std::string ColorHex = "#1A1A1A";
14+
std::string ColorDarkHex = "#000000";
1315

1416
float TeamBoost = 0.0;
1517

0 commit comments

Comments
 (0)