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

Commit

Permalink
Add "show/hide_player_info" message settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
enzanki-ars committed May 11, 2020
1 parent 5630785 commit d2a2678
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# StreamGraphicsGSI-RL

Version: 1.3.1
Version: 1.4.0

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

Expand Down
48 changes: 43 additions & 5 deletions StreamGraphicsGSI-RL/StreamGraphicsGSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
#include <sstream>
#include <iomanip>

BAKKESMOD_PLUGIN(StreamGraphicsGSI, "StreamGraphicsGSI", "1.3.1", PLUGINTYPE_THREADED)
BAKKESMOD_PLUGIN(StreamGraphicsGSI, "StreamGraphicsGSI", "1.4.0", PLUGINTYPE_THREADED)

using placeholders::_1;

const float COLOR_DARKEN = 0.75;
bool PLAYER_INFO_DISPLAY_STATE = false;

#pragma region Plugin Methods
void StreamGraphicsGSI::onLoad()
{
cvarManager->registerCvar("streamgraphics_gsi_url", "http://192.168.1.70:8000/api/v1/set_multiple_for_path_and_flatten/data/com/rocketleague/gsi", "HTTP server url to send the JSON post to.", true, false, 0, false, 0, true);
cvarManager->registerCvar("streamgraphics_gsi_url", "http://192.168.1.70:8000/api/v1/", "Base HTTP server url.", true, false, 0, false, 0, true);
cvarManager->registerCvar("streamgraphics_gsi_url_data", "set_multiple_for_path_and_flatten/data/com/rocketleague/gsi", "HTTP server url to send the JSON data to.", true, false, 0, false, 0, true);
cvarManager->registerCvar("streamgraphics_gsi_url_show_player_info", "easy_set/overlay/rocketleague-gsi-spec-info/display/fade-in", "HTTP server url to run show-player-info.", true, false, 0, false, 0, true);
cvarManager->registerCvar("streamgraphics_gsi_url_hide_player_info", "easy_set/overlay/rocketleague-gsi-spec-info/display/fade-out", "HTTP server url to run hide-player-info.", true, false, 0, false, 0, true);

this->gameWrapper->HookEventPost("Function GameEvent_Soccar_TA.ReplayPlayback.BeginState", std::bind(&StreamGraphicsGSI::ReplayStartEvent, this, _1));
this->gameWrapper->HookEventPost("Function GameEvent_Soccar_TA.ReplayPlayback.EndState", std::bind(&StreamGraphicsGSI::ReplayEndEvent, this, _1));
Expand Down Expand Up @@ -43,11 +47,33 @@ void StreamGraphicsGSI::StartLoop() {
void StreamGraphicsGSI::SendToStreamGraphics(std::string data)
{
try {
http::Request request(cvarManager->getCvar("streamgraphics_gsi_url").getStringValue());
http::Request request(cvarManager->getCvar("streamgraphics_gsi_url").getStringValue() + cvarManager->getCvar("streamgraphics_gsi_url_data").getStringValue());
(void)request.send("POST", data, { "Content-Type: application/json" });
}
catch (...) {
cvarManager->log("Failed GSI HTTP POST: Please reload the plugin to try again. Using URL - " + cvarManager->getCvar("streamgraphics_gsi_url").getStringValue());
cvarManager->log("Failed GSI HTTP POST: Please reload the plugin to try again. Using URL - " + cvarManager->getCvar("streamgraphics_gsi_url").getStringValue() + cvarManager->getCvar("streamgraphics_gsi_url_data").getStringValue());
ok = false;
}
}
void StreamGraphicsGSI::ShowPlayerInfo()
{
try {
http::Request request(cvarManager->getCvar("streamgraphics_gsi_url").getStringValue() + cvarManager->getCvar("streamgraphics_gsi_url_show_player_info").getStringValue());
(void)request.send("POST");
}
catch (...) {
cvarManager->log("Failed GSI HTTP POST (show-player-info): Please reload the plugin to try again. Using URL - " + cvarManager->getCvar("streamgraphics_gsi_url").getStringValue() + cvarManager->getCvar("streamgraphics_gsi_url_show_player_info").getStringValue());
ok = false;
}
}
void StreamGraphicsGSI::HidePlayerInfo()
{
try {
http::Request request(cvarManager->getCvar("streamgraphics_gsi_url").getStringValue() + cvarManager->getCvar("streamgraphics_gsi_url_hide_player_info").getStringValue());
(void)request.send("POST");
}
catch (...) {
cvarManager->log("Failed GSI HTTP POST (show-player-info): Please reload the plugin to try again. Using URL - " + cvarManager->getCvar("streamgraphics_gsi_url").getStringValue() + cvarManager->getCvar("streamgraphics_gsi_url_hide_player_info").getStringValue());
ok = false;
}
}
Expand Down Expand Up @@ -272,6 +298,10 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {

GameState.CurrentSpec.CurrentBoostAmount = boost;

if (!GameState.IsSpectatingPlayerPOV && !GameState.InReplayMode) {
ShowPlayerInfo();
}

GameState.IsSpectatingPlayerPOV = true;
}
else {
Expand All @@ -294,6 +324,10 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {

GameState.CurrentSpec.CurrentBoostAmount = 0;

if (GameState.IsSpectatingPlayerPOV || GameState.InReplayMode) {
HidePlayerInfo();
}

GameState.IsSpectatingPlayerPOV = false;
}
}
Expand Down Expand Up @@ -373,6 +407,10 @@ void StreamGraphicsGSI::UpdateState(ServerWrapper wrapper) {

void StreamGraphicsGSI::ResetStates()
{
if (GameState.IsSpectatingPlayerPOV || GameState.InReplayMode) {
HidePlayerInfo();
}

GameState.Status = GameStatus::Menu;

GameState.Match.Playlist = -1;
Expand All @@ -389,7 +427,7 @@ void StreamGraphicsGSI::ResetStates()
GameState.Match.Teams[0].TeamBoost = 0.0;
GameState.Match.Teams[0].Name = "";
GameState.Match.Teams[0].ColorHex = "#1A1A1A";
GameState.Match.Teams[1].ColorDarkHex = "#000000";
GameState.Match.Teams[0].ColorDarkHex = "#000000";

GameState.Match.Teams[1].Index = 1;
GameState.Match.Teams[1].PlayerCount = 0;
Expand Down
2 changes: 2 additions & 0 deletions StreamGraphicsGSI-RL/StreamGraphicsGSI.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class StreamGraphicsGSI : public BakkesMod::Plugin::BakkesModPlugin
#pragma region StreamGraphics
void StartLoop();
void SendToStreamGraphics(std::string);
void ShowPlayerInfo();
void HidePlayerInfo();
#pragma endregion

#pragma region Events
Expand Down

0 comments on commit d2a2678

Please sign in to comment.