diff --git a/.gitignore b/.gitignore
index 5b0f478a..5d60286c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
.vs/
-build/
-plugins/
+Release/
+x64/
RocketStatsNusa/*
!RocketStatsNusa/*.cpp
!RocketStatsNusa/*.h
diff --git a/RocketStats.sln b/RocketStats.sln
index 1105f8b5..f22e4842 100644
--- a/RocketStats.sln
+++ b/RocketStats.sln
@@ -1,22 +1,22 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
-VisualStudioVersion = 16.0.32106.194
+VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RocketStats", "RocketStats/RocketStats.vcxproj", "{3A9A96B9-4537-4B8E-8164-181A6B3C8B7F}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RocketStats", "RocketStats\RocketStats.vcxproj", "{99C07F6D-C7AD-499D-B9D8-880EEDF0A2D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3A9A96B9-4537-4B8E-8164-181A6B3C8B7F}.Release|x64.ActiveCfg = Release|x64
- {3A9A96B9-4537-4B8E-8164-181A6B3C8B7F}.Release|x64.Build.0 = Release|x64
+ {99C07F6D-C7AD-499D-B9D8-880EEDF0A2D0}.Release|x64.ActiveCfg = Release|x64
+ {99C07F6D-C7AD-499D-B9D8-880EEDF0A2D0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {38C8FFD4-CAFC-42B7-B30C-4745DE24D9B0}
+ SolutionGuid = {FFB97C48-88FC-4296-8A11-1B5C324BCB26}
EndGlobalSection
EndGlobal
diff --git a/RocketStats/BakkesMod.props b/RocketStats/BakkesMod.props
deleted file mode 100644
index c2985a49..00000000
--- a/RocketStats/BakkesMod.props
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- $(registry:HKEY_CURRENT_USER\Software\BakkesMod\AppPath@BakkesModPath)
-
-
-
- $(BakkesModPath)\bakkesmodsdk\include;%(AdditionalIncludeDirectories)
-
-
- $(BakkesModPath)\bakkesmodsdk\lib;%(AdditionalLibraryDirectories)
- pluginsdk.lib;%(AdditionalDependencies)
-
-
- "$(BakkesModPath)\bakkesmodsdk\bakkesmod-patch.exe" "$(TargetPath)"
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/RocketStats/RS_BoostHooks.cpp b/RocketStats/RS_BoostHooks.cpp
deleted file mode 100644
index a221833b..00000000
--- a/RocketStats/RS_BoostHooks.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::OnBoostStart(std::string eventName)
- {
- cvarManager->log("boostStart");
- // Check if boost enabled in options
- bool IsBoostEnabled = cvarManager->getCvar("RocketStats_stop_boost").getBoolValue();
- if (!IsBoostEnabled || gameWrapper->IsInReplay() || isBoosting)
- return;
-
- CarWrapper cWrap = gameWrapper->GetLocalCar();
-
- if (!cWrap.IsNull())
- {
- BoostWrapper bWrap = cWrap.GetBoostComponent();
-
- if (!bWrap.IsNull() && bWrap.GetbActive() == 1 && !isBoosting)
- {
- isBoosting = true;
- WriteInFile("RocketStats_images/BoostState.txt", std::to_string(1));
- }
- }
-
- return;
- }
-
- void RocketStats::OnBoostEnd(std::string eventName)
- {
- cvarManager->log("boostEnd");
- // Check if boost enabled in options
- bool IsBoostEnabled = cvarManager->getCvar("RocketStats_stop_boost").getBoolValue();
- if (!IsBoostEnabled || gameWrapper->IsInReplay() || !isBoosting)
- return;
-
- CarWrapper cWrap = gameWrapper->GetLocalCar();
-
- if (!cWrap.IsNull())
- {
- BoostWrapper bWrap = cWrap.GetBoostComponent();
-
- if (!bWrap.IsNull() && bWrap.GetbActive() == 0 && isBoosting)
- {
- isBoosting = false;
- WriteInFile("RocketStats_images/BoostState.txt", std::to_string(0));
- }
- }
- return;
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_FileIO.cpp b/RocketStats/RS_FileIO.cpp
deleted file mode 100644
index 53cfe942..00000000
--- a/RocketStats/RS_FileIO.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::WriteInFile(std::string _filename, std::string _value)
- {
- std::ofstream stream(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\" + _filename, std::ios::out | std::ios::trunc);
-
- if (stream.is_open())
- {
- stream << _value;
- stream.close();
- }
- else
- {
- cvarManager->log("Can't write to file: " + _filename);
- cvarManager->log("Value to write was: " + _value);
- }
- }
-
- void RocketStats::writeGameMode()
- {
- WriteInFile("RocketStats_GameMode.txt", GetPlaylistName(currentPlaylist));
- }
-
- void RocketStats::writeMMR()
- {
- std::string tmp;
- if (cvarManager->getCvar("RS_enable_float").getBoolValue())
- tmp = to_string_with_precision(stats[currentPlaylist].myMMR, 2);
- else
- tmp = std::to_string(int(stats[currentPlaylist].myMMR));
- WriteInFile("RocketStats_MMR.txt", tmp);
- }
- void RocketStats::writeMMRChange()
- {
- bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
- Stats current = (RS_session == true) ? session : stats[currentPlaylist];
-
- std::string tmp;
- if (cvarManager->getCvar("RS_enable_float").getBoolValue())
- tmp = to_string_with_precision(current.MMRChange, 2);
- else
- tmp = std::to_string(int(current.MMRChange));
-
- if (current.MMRChange > 0)
- WriteInFile("RocketStats_MMRChange.txt", "+" + tmp);
- else
- WriteInFile("RocketStats_MMRChange.txt", tmp);
- }
-
- void RocketStats::writeStreak()
- {
- bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
- Stats current = (RS_session == true) ? session : stats[currentPlaylist];
-
- if (current.streak > 0)
- WriteInFile("RocketStats_Streak.txt", "+" + std::to_string(current.streak));
- else
- WriteInFile("RocketStats_Streak.txt", std::to_string(current.streak));
- }
-
- void RocketStats::writeWin()
- {
- bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
- Stats current = (RS_session == true) ? session : stats[currentPlaylist];
- WriteInFile("RocketStats_Win.txt", std::to_string(current.win));
- }
-
- void RocketStats::writeLosses()
- {
- bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
- Stats current = (RS_session == true) ? session : stats[currentPlaylist];
- WriteInFile("RocketStats_Loose.txt", std::to_string(current.losses));
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_GameHooks.cpp b/RocketStats/RS_GameHooks.cpp
deleted file mode 100644
index 391935b9..00000000
--- a/RocketStats/RS_GameHooks.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::GameStart(std::string eventName)
- {
- if (!gameWrapper->IsInOnlineGame() || isGameStarted)
- return;
-
- cvarManager->log("===== GameStart =====");
- CarWrapper me = gameWrapper->GetLocalCar();
- if (me.IsNull())
- return;
-
- PriWrapper mePRI = me.GetPRI();
- if (mePRI.IsNull())
- return;
-
- TeamInfoWrapper myTeam = mePRI.GetTeam();
- if (myTeam.IsNull())
- return;
-
- MMRWrapper mmrw = gameWrapper->GetMMRWrapper();
- currentPlaylist = mmrw.GetCurrentPlaylist();
- SkillRank playerRank = mmrw.GetPlayerRank(gameWrapper->GetUniqueID(), currentPlaylist);
- cvarManager->log(std::to_string(currentPlaylist) + " -> " + GetPlaylistName(currentPlaylist));
-
- writeGameMode();
- writeMMRChange();
- writeWin();
- writeStreak();
- writeLosses();
- writeMMR();
-
- // Get TeamNum
- myTeamNum = myTeam.GetTeamNum();
-
- // Set Game Started
- isGameStarted = true;
- isGameEnded = false;
-
- UpdateMMR(gameWrapper->GetUniqueID());
- WriteInFile("RocketStats_images/BoostState.txt", std::to_string(0));
- }
-
- void RocketStats::GameEnd(std::string eventName)
- {
- if (gameWrapper->IsInOnlineGame() && myTeamNum != -1)
- {
- cvarManager->log("===== GameEnd =====");
- ServerWrapper server = gameWrapper->GetOnlineGame();
- TeamWrapper winningTeam = server.GetGameWinner();
- if (winningTeam.IsNull())
- return;
-
- int teamnum = winningTeam.GetTeamNum();
-
- // Game as ended
- isGameEnded = true;
-
- MMRWrapper mw = gameWrapper->GetMMRWrapper();
-
- if (myTeamNum == winningTeam.GetTeamNum())
- {
- cvarManager->log("===== Game Won =====");
- // On Win, Increase streak and Win Number
- stats[currentPlaylist].win++;
- session.win++;
-
- if (stats[currentPlaylist].streak < 0)
- {
- session.streak = 1;
- stats[currentPlaylist].streak = 1;
- }
- else
- {
- session.streak += 1;
- stats[currentPlaylist].streak++;
- }
-
- writeWin();
- }
- else
- {
- cvarManager->log("===== Game Lost =====");
- // On Loose, Increase loose Number and decrease streak
- stats[currentPlaylist].losses++;
- session.losses++;
- if (stats[currentPlaylist].streak > 0)
- {
- session.streak = -1;
- stats[currentPlaylist].streak = -1;
- }
- else
- {
- session.streak--;
- stats[currentPlaylist].streak--;
- }
-
- writeLosses();
- }
-
- writeStreak();
-
- // Reset myTeamNum security
- myTeamNum = -1;
-
- WriteInFile("RocketStats_images/BoostState.txt", std::to_string(-1));
-
- gameWrapper->SetTimeout([&](GameWrapper* gameWrapper)
- { UpdateMMR(gameWrapper->GetUniqueID()); },
- 3.0F);
- }
- }
-
- void RocketStats::GameDestroyed(std::string eventName)
- {
- cvarManager->log("===== GameDestroyed =====");
- // Check if Game Ended, if not, RAGE QUIT or disconnect
- if (isGameStarted == true && isGameEnded == false)
- {
- session.losses++;
- stats[currentPlaylist].losses++;
- if (stats[currentPlaylist].streak > 0)
- {
- session.streak = 0;
- stats[currentPlaylist].streak = -1;
- }
- else
- {
- session.streak--;
- stats[currentPlaylist].streak--;
- }
-
- writeStreak();
- writeLosses();
- }
- isGameEnded = true;
- isGameStarted = false;
- WriteInFile("RocketStats_images/BoostState.txt", std::to_string(-1));
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_Overlay.cpp b/RocketStats/RS_Overlay.cpp
deleted file mode 100644
index 9b6932f1..00000000
--- a/RocketStats/RS_Overlay.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::DisplayRank(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, float scale, bool showText)
- {
- if (currentTier >= rank_nb)
- {
- currentTier = 0;
- }
- std::shared_ptr image = rank[currentTier].image;
-
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(imagePos);
- if (image->IsLoadedForCanvas())
- canvas.DrawTexture(image.get(), 0.5f * scale);
-
- if (showText)
- {
- std::string tmpRank = currentRank;
- replaceAll(tmpRank, "_", " ");
- canvas.SetPosition(textPos_tmp);
- if (currentDivision == "")
- canvas.DrawString(tmpRank, 2.0f * scale, 2.0f * scale);
- else
- canvas.DrawString(tmpRank + " " + currentDivision, 2.0f * scale, 2.0f * scale);
- }
- }
- void RocketStats::DisplayMMR(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage)
- {
- std::string mmr = to_string_with_precision(current.myMMR, 2);
- std::string change = to_string_with_precision(current.MMRChange, 2);
-
- if (showImage)
- {
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(imagePos);
- if (crown->IsLoadedForCanvas())
- canvas.DrawTexture(crown.get(), 0.5f * scale);
- }
-
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(textPos_tmp);
- if (current.MMRChange > 0)
- change = "+" + change;
- canvas.DrawString(mmr + " (" + change + ")", 2.0f * scale, 2.0f * scale);
- }
- void RocketStats::DisplayWins(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale)
- {
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(imagePos);
- if (win->IsLoadedForCanvas())
- canvas.DrawTexture(win.get(), 0.5f * scale);
-
- canvas.SetColor(LinearColor{ 0, 255, 0, 255 });
- canvas.SetPosition(textPos_tmp);
- canvas.DrawString(std::to_string(current.win), 2.0f * scale, 2.0f * scale);
- }
- void RocketStats::DisplayLoose(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale)
- {
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(imagePos);
- if (loose->IsLoadedForCanvas())
- canvas.DrawTexture(loose.get(), 0.5f * scale);
-
- canvas.SetColor(LinearColor{ 255, 0, 0, 255 });
- canvas.SetPosition(textPos_tmp);
- canvas.DrawString(std::to_string(current.losses), 2.0f * scale, 2.0f * scale);
- }
- void RocketStats::DisplayStreak(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage)
- {
- if (showImage)
- {
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(imagePos);
- if (streak->IsLoadedForCanvas())
- canvas.DrawTexture(streak.get(), 0.5f * scale);
- }
-
- canvas.SetColor(LinearColor{ 255, 255, 255, 255 });
- canvas.SetPosition(textPos_tmp);
-
- if (current.streak < 0)
- canvas.SetColor(LinearColor{ 255, 0, 0, 255 });
- else
- canvas.SetColor(LinearColor{ 0, 255, 0, 255 });
-
- std::string streak = std::to_string(current.streak);
- if (current.streak > 0)
- streak = "+" + streak;
-
- canvas.DrawString(streak, 2.0f * scale, 2.0f * scale);
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_Rank.cpp b/RocketStats/RS_Rank.cpp
deleted file mode 100644
index d21cefe8..00000000
--- a/RocketStats/RS_Rank.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::InitRank()
- {
- lastGameMode = 0;
- currentGameMode = 0;
- currentMMR = 0;
- currentRank = "norank";
- currentDivision = "nodiv";
- lastRank = "norank";
-
- // std::string _value = "";
-
- // WriteInFile("RocketStats_images/rank.html", _value);
- }
-
- void RocketStats::MajRank(int _gameMode, bool isRanked, float _currentMMR, SkillRank playerRank)
- {
- currentGameMode = _gameMode;
- currentMMR = _currentMMR;
- currentTier = playerRank.Tier;
-
- if (isRanked)
- {
- if (currentGameMode != 34 && playerRank.MatchesPlayed < 10)
- {
- currentRank = "Placement: " + std::to_string(playerRank.MatchesPlayed) + "/10";
- currentDivision = "";
- }
- else
- {
- currentRank = GetRank(playerRank.Tier);
- currentDivision = "Div. " + std::to_string(playerRank.Division + 1);
- WriteInFile("RocketStats_Div.txt", currentDivision);
- }
-
- if (currentRank != lastRank)
- {
- // std::string _value = "";
-
- // WriteInFile("RocketStats_images/rank.html", _value);
- WriteInFile("RocketStats_Rank.txt", currentRank);
- }
- }
- else
- {
- currentRank = GetPlaylistName(currentGameMode);
- currentDivision = "";
-
- // std::string _value = "";
-
- // WriteInFile("RocketStats_images/rank.html", _value);
- WriteInFile("RocketStats_Rank.txt", currentRank);
- }
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_Render.cpp b/RocketStats/RS_Render.cpp
deleted file mode 100644
index 1697500a..00000000
--- a/RocketStats/RS_Render.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::Render(CanvasWrapper canvas)
- {
- bool RS_disp_ig = cvarManager->getCvar("RS_disp_ig").getBoolValue();
- bool RS_hide_overlay_ig = cvarManager->getCvar("RS_hide_overlay_ig").getBoolValue();
-
- if (!RS_disp_ig || isGameStarted && !isGameEnded && RS_hide_overlay_ig)
- return;
-
- bool RS_Use_v1 = cvarManager->getCvar("RS_Use_v1").getBoolValue();
- bool RS_Use_v2 = cvarManager->getCvar("RS_Use_v2").getBoolValue();
- bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
- float RS_x_position = cvarManager->getCvar("RS_x_position").getFloatValue();
- float RS_y_position = cvarManager->getCvar("RS_y_position").getFloatValue();
- float RS_scale = cvarManager->getCvar("RS_scale").getFloatValue();
- Stats current = (RS_session == true) ? session : stats[currentPlaylist];
-
- if (RS_Use_v1)
- {
- std::vector RS_values = {
- "RS_disp_gamemode",
- "RS_disp_rank",
- "RS_disp_mmr",
- "RS_disp_wins",
- "RS_disp_losses",
- "RS_disp_streak",
- };
-
- unsigned int size = 0;
- for (auto& it : RS_values)
- {
- bool tmp = cvarManager->getCvar(it).getBoolValue();
- if (tmp)
- size += 1;
- if (it == "RS_disp_mmr")
- size += 1;
- }
-
- // Draw box here
- Vector2 drawLoc = {
- int(canvas.GetSize().X * RS_x_position),
- int(canvas.GetSize().Y * RS_y_position) };
- Vector2 sizeBox = {
- int(175 * RS_scale),
- int((23 * size) * RS_scale) };
- canvas.SetPosition(drawLoc);
-
- // Set background color
- canvas.SetColor(LinearColor{ 0, 0, 0, 150 });
- canvas.FillBox(sizeBox);
-
- // Draw text
- Vector2 textPos = { int(drawLoc.X + 10), int(drawLoc.Y + 10) };
- for (auto& it : RS_values)
- {
- bool tmp = cvarManager->getCvar(it).getBoolValue();
-
- if (tmp)
- {
- // Set the position
- canvas.SetPosition(textPos);
-
- // Set Color and Text for the value
- if (it == "RS_disp_gamemode")
- {
- canvas.SetColor(LinearColor{ 180, 180, 180, 255 });
- canvas.DrawString(GetPlaylistName(currentPlaylist), RS_scale, RS_scale);
- }
- else if (it == "RS_disp_rank")
- {
- std::string tmpRank = currentRank;
- if (currentTier >= rank_nb)
- currentTier = 0;
- replaceAll(tmpRank, "_", " ");
- canvas.SetColor(LinearColor{ 180, 180, 180, 255 });
- if (currentDivision == "")
- canvas.DrawString(tmpRank, RS_scale, RS_scale);
- else
- canvas.DrawString(tmpRank + " " + currentDivision, RS_scale, RS_scale);
- }
- else if (it == "RS_disp_mmr")
- {
- canvas.SetColor(LinearColor{ 180, 180, 180, 255 });
- std::string mmr = to_string_with_precision(current.myMMR, 2);
- canvas.DrawString("MMR : " + mmr, RS_scale, RS_scale);
-
- textPos.Y += int(20 * RS_scale);
- canvas.SetPosition(textPos);
-
- std::string mmrchange = to_string_with_precision(current.MMRChange, 2);
- if (current.MMRChange >= 0)
- {
- canvas.SetColor(LinearColor{ 30, 224, 24, 255 });
- canvas.DrawString("MMRChange : +" + mmrchange, RS_scale, RS_scale);
- }
- else
- {
- canvas.SetColor(LinearColor{ 224, 24, 24, 255 });
- canvas.DrawString("MMRChange : " + mmrchange, RS_scale, RS_scale);
- }
- }
- else if (it == "RS_disp_wins")
- {
- canvas.SetColor(LinearColor{ 30, 224, 24, 255 });
- canvas.DrawString("Win : " + std::to_string(current.win), RS_scale, RS_scale);
- }
- else if (it == "RS_disp_losses")
- {
- canvas.SetColor(LinearColor{ 224, 24, 24, 255 });
- canvas.DrawString("Losses : " + std::to_string(current.losses), RS_scale, RS_scale);
- }
- else if (it == "RS_disp_streak")
- {
- if (current.streak >= 0)
- {
- canvas.SetColor(LinearColor{ 30, 224, 24, 255 });
- canvas.DrawString("Streak : +" + std::to_string(current.streak), RS_scale, RS_scale);
- }
- else
- {
- canvas.SetColor(LinearColor{ 224, 24, 24, 255 });
- canvas.DrawString("Streak : " + std::to_string(current.streak), RS_scale, RS_scale);
- }
- }
- // Increase Y position
- textPos.Y += int(20 * RS_scale);
- }
- }
- }
- else if (RS_Use_v2)
- {
- auto canSize = canvas.GetSize();
- Vector2 imagePos = { int(RS_x_position * canSize.X), int(RS_y_position * canSize.Y) };
- Vector2 textPos_tmp = imagePos;
-
- textPos_tmp.X += int(50 * RS_scale);
- textPos_tmp.Y += int(10 * RS_scale);
-
- // Display Rank
- if (cvarManager->getCvar("RS_disp_rank").getBoolValue())
- {
- DisplayRank(canvas, imagePos, textPos_tmp, RS_scale, true);
- imagePos.Y += int(50 * RS_scale);
- textPos_tmp.Y += int(50 * RS_scale);
- }
-
- // Display MMR
- if (cvarManager->getCvar("RS_disp_mmr").getBoolValue())
- {
- DisplayMMR(canvas, imagePos, textPos_tmp, current, RS_scale, true);
- imagePos.Y += int(50 * RS_scale);
- textPos_tmp.Y += int(50 * RS_scale);
- }
-
- // Display Win
- if (cvarManager->getCvar("RS_disp_wins").getBoolValue())
- {
- DisplayWins(canvas, imagePos, textPos_tmp, current, RS_scale);
- imagePos.Y += int(50 * RS_scale);
- textPos_tmp.Y += int(50 * RS_scale);
- }
-
- // Display Loose
- if (cvarManager->getCvar("RS_disp_losses").getBoolValue())
- {
- DisplayLoose(canvas, imagePos, textPos_tmp, current, RS_scale);
- }
-
- // Display Streak
- if (cvarManager->getCvar("RS_disp_streak").getBoolValue())
- {
- textPos_tmp.X += int(75 * RS_scale);
- textPos_tmp.Y -= int(25 * RS_scale);
- DisplayStreak(canvas, imagePos, textPos_tmp, current, RS_scale, false);
- }
- }
- else
- {
- const bool displayRank = cvarManager->getCvar("RS_disp_rank").getBoolValue();
- const bool displayMMR = cvarManager->getCvar("RS_disp_mmr").getBoolValue();
- const bool displayWins = cvarManager->getCvar("RS_disp_wins").getBoolValue();
- const bool displayLosses = cvarManager->getCvar("RS_disp_losses").getBoolValue();
- const bool displayStreak = cvarManager->getCvar("RS_disp_streak").getBoolValue();
- int size = 0;
-
- if (displayRank)
- size += 70;
- if (displayMMR)
- size += 250;
- if (displayWins)
- size += 110;
- if (displayLosses)
- size += 110;
- if (displayStreak)
- size += 110;
- if (displayWins || displayLosses || displayStreak)
- size += 50;
-
- auto canSize = canvas.GetSize();
-
- // Draw box here
- Vector2 backgroundPos = { int(RS_x_position * canSize.X), int(RS_y_position * canSize.Y) };
- Vector2 sizeBox = {
- int(size * RS_scale),
- int(50 * RS_scale) };
- canvas.SetPosition(backgroundPos);
- canvas.SetColor(LinearColor{ 0, 0, 0, 255 });
- canvas.FillBox(sizeBox);
-
- Vector2 imagePos = backgroundPos;
- imagePos.X += int(30 * RS_scale);
-
- Vector2 textPos_tmp = imagePos;
- textPos_tmp.Y += int(10 * RS_scale);
-
- // Display Rank
- if (displayRank)
- {
- DisplayRank(canvas, imagePos, textPos_tmp, RS_scale, false);
- imagePos.X += int(70 * RS_scale);
- textPos_tmp.X += int(70 * RS_scale);
- }
-
- // Display MMR
- if (displayMMR)
- {
- DisplayMMR(canvas, imagePos, textPos_tmp, current, RS_scale, false);
- imagePos.X += int(250 * RS_scale);
- textPos_tmp.X += int(250 * RS_scale);
- }
-
- // Adjust text postition for the rest with images
- textPos_tmp.X += int(70 * RS_scale);
-
- // Display Win
- if (displayWins)
- {
- DisplayWins(canvas, imagePos, textPos_tmp, current, RS_scale);
- imagePos.X += int(110 * RS_scale);
- textPos_tmp.X += int(110 * RS_scale);
- }
-
- // Display Loose
- if (displayLosses)
- {
- DisplayLoose(canvas, imagePos, textPos_tmp, current, RS_scale);
- imagePos.X += int(110 * RS_scale);
- textPos_tmp.X += int(110 * RS_scale);
- }
-
- // Display Streak
- if (displayStreak)
- {
- DisplayStreak(canvas, imagePos, textPos_tmp, current, RS_scale, true);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_Stats.cpp b/RocketStats/RS_Stats.cpp
deleted file mode 100644
index d6fac5d9..00000000
--- a/RocketStats/RS_Stats.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- void RocketStats::UpdateMMR(UniqueIDWrapper id)
- {
- cvarManager->log("===== updateMMR =====");
-
- if (id.GetIdString() != gameWrapper->GetUniqueID().GetIdString()) {
- cvarManager->log("not the user");
- return;
- }
-
- if (currentPlaylist == 0)
- {
- cvarManager->log("Invalid playlist id. Have you just opened the game ?");
- return;
- }
-
- MMRWrapper mmrw = gameWrapper->GetMMRWrapper();
- float mmr = mmrw.GetPlayerMMR(id, currentPlaylist);
- SkillRank playerRank = mmrw.GetPlayerRank(id, currentPlaylist);
-
- if (stats[currentPlaylist].isInit == false)
- {
- stats[currentPlaylist].myMMR = mmr;
- stats[currentPlaylist].isInit = true;
- }
- stats[currentPlaylist].MMRChange = stats[currentPlaylist].MMRChange + (mmr - stats[currentPlaylist].myMMR);
- stats[currentPlaylist].myMMR = mmr;
-
- MajRank(currentPlaylist, mmrw.IsRanked(currentPlaylist), stats[currentPlaylist].myMMR, playerRank);
- SessionStats();
- writeMMR();
- writeMMRChange();
- }
-
- void RocketStats::SessionStats()
- {
- Stats tmp;
-
- for (auto it = playlistName.begin(); it != playlistName.end(); it++)
- {
- tmp.MMRChange += stats[it->first].MMRChange;
- tmp.win += stats[it->first].win;
- tmp.losses += stats[it->first].losses;
- }
-
- session.myMMR = stats[currentPlaylist].myMMR;
- session.MMRChange = tmp.MMRChange;
- session.win = tmp.win;
- session.losses = tmp.losses;
- }
-
- void RocketStats::ResetStats()
- {
- for (auto& kv : stats)
- {
- kv.second = Stats();
- }
- session = Stats();
- WriteInFile("RocketStats_Win.txt", std::to_string(0));
- WriteInFile("RocketStats_Streak.txt", std::to_string(0));
- WriteInFile("RocketStats_Loose.txt", std::to_string(0));
- WriteInFile("RocketStats_MMRChange.txt", std::to_string(0));
- WriteInFile("RocketStats_MMR.txt", std::to_string(0));
- WriteInFile("RocketStats_Rank.txt", "");
- WriteInFile("RocketStats_Div.txt", "");
- WriteInFile("RocketStats_GameMode.txt", "");
-
- InitRank();
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RS_Utils.cpp b/RocketStats/RS_Utils.cpp
deleted file mode 100644
index c6412d83..00000000
--- a/RocketStats/RS_Utils.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "pch.h"
-#include "RocketStats.h"
-
-namespace NS_RS {
- std::string RocketStats::GetRank(int tierID)
- {
- cvarManager->log("tier: " + std::to_string(tierID));
- if (tierID < rank_nb)
- return rank[tierID].name;
- else
- return "Unranked";
- }
-
- std::string RocketStats::GetPlaylistName(int playlistID)
- {
- if (playlistName.find(playlistID) != playlistName.end())
- return playlistName.at(playlistID);
- else
- return "Unknown Game Mode";
- }
-
- void RocketStats::LoadImgs()
- {
- int load_check = 0;
-
- crown = std::make_shared(gameWrapper->GetBakkesModPath() / "RocketStats" / "RocketStats_images" / "crown.png", true);
- load_check += (int)crown->LoadForCanvas();
- LogImageLoadStatus(crown->LoadForCanvas(), "crown");
-
- win = std::make_shared(gameWrapper->GetBakkesModPath() / "RocketStats" / "RocketStats_images" / "win.png", true);
- load_check += (int)win->LoadForCanvas();
- LogImageLoadStatus(win->LoadForCanvas(), "win");
-
- loose = std::make_shared(gameWrapper->GetBakkesModPath() / "RocketStats" / "RocketStats_images" / "loose.png", true);
- load_check += (int)loose->LoadForCanvas();
- LogImageLoadStatus(loose->LoadForCanvas(), "loose");
-
- streak = std::make_shared(gameWrapper->GetBakkesModPath() / "RocketStats" / "RocketStats_images" / "streak.png", true);
- load_check += (int)streak->LoadForCanvas();
- LogImageLoadStatus(streak->LoadForCanvas(), "streak");
-
- for (int i = 0; i < rank_nb; i++)
- {
- rank[i].image = std::make_shared(gameWrapper->GetBakkesModPath() / "RocketStats" / "RocketStats_images" / (rank[i].name + ".png"), true);
- load_check += (int)rank[i].image->LoadForCanvas();
- LogImageLoadStatus(rank[i].image->LoadForCanvas(), rank[i].name);
- }
- cvarManager->log(std::to_string(load_check) + "/27 images were loaded successfully");
- }
-
- void RocketStats::LogImageLoadStatus(bool status, std::string imageName)
- {
- if (status)
- cvarManager->log(imageName + ": image load");
- else
- cvarManager->log(imageName + ": failed to load");
- }
-}
\ No newline at end of file
diff --git a/RocketStats/RocketStats.cpp b/RocketStats/RocketStats.cpp
index ad87f2d5..b1ea34d4 100644
--- a/RocketStats/RocketStats.cpp
+++ b/RocketStats/RocketStats.cpp
@@ -1,70 +1,879 @@
-#include "pch.h"
+/* ==================================
+ * Developped by Lyliya & NuSa
+ * ================================== */
+
#include "RocketStats.h"
+#include
+#include
+
+BAKKESMOD_PLUGIN(RocketStats, "RocketStats", "3.5", PERMISSION_ALL)
+
+#pragma region utils
+std::string RocketStats::GetRank(int tierID)
+{
+ cvarManager->log("tier: " + std::to_string(tierID));
+ if (tierID < rank_nb)
+ return rank[tierID].name;
+ else
+ return "Unranked";
+}
+
+std::string RocketStats::GetPlaylistName(int playlistID)
+{
+ if (playlistName.find(playlistID) != playlistName.end())
+ return playlistName.at(playlistID);
+ else
+ return "Unknown Game Mode";
+}
+
+void RocketStats::replaceAll(std::string &str, const std::string &from, const std::string &to)
+{
+ while (replace(str, from, to))
+ {
+ }
+}
+
+void RocketStats::LoadImgs()
+{
+ int load_check = 0;
+
+ crown = std::make_shared(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\RocketStats_images\\crown.png", true);
+ load_check += (int)crown->LoadForCanvas();
+ LogImageLoadStatus(crown->LoadForCanvas(), "crown");
+
+ win = std::make_shared(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\RocketStats_images\\win.png", true);
+ load_check += (int)win->LoadForCanvas();
+ LogImageLoadStatus(win->LoadForCanvas(), "win");
+
+ loose = std::make_shared(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\RocketStats_images\\loose.png", true);
+ load_check += (int)loose->LoadForCanvas();
+ LogImageLoadStatus(loose->LoadForCanvas(), "loose");
+
+ streak = std::make_shared(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\RocketStats_images\\streak.png", true);
+ load_check += (int)streak->LoadForCanvas();
+ LogImageLoadStatus(streak->LoadForCanvas(), "streak");
+
+ for (int i = 0; i < rank_nb; i++)
+ {
+ rank[i].image = std::make_shared(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\RocketStats_images\\" + rank[i].name + ".png", true);
+ load_check += (int)rank[i].image->LoadForCanvas();
+ LogImageLoadStatus(rank[i].image->LoadForCanvas(), rank[i].name);
+ }
+ cvarManager->log(std::to_string(load_check) + "/27 images were loaded successfully");
+}
+
+void RocketStats::LogImageLoadStatus(bool status, std::string imageName)
+{
+ if (status)
+ cvarManager->log(imageName + ": image load");
+ else
+ cvarManager->log(imageName + ": failed to load");
+}
+#pragma endregion
+
+#pragma region PluginLoadRoutines
+void RocketStats::onLoad()
+{
+ // notifierToken = gameWrapper->GetMMRWrapper().RegisterMMRNotifier(std::bind(&RocketStats::UpdateMMR, this, std::placeholders::_1));
+
+ LoadImgs();
+
+ cvarManager->registerNotifier(
+ "RocketStats_reset_stats",
+ [this](std::vector params)
+ { ResetStats(); },
+ "Reset Stats",
+ PERMISSION_ALL);
+
+ cvarManager->registerNotifier(
+ "RocketStats_reload_images",
+ [this](std::vector params)
+ { LoadImgs(); },
+ "Reload images",
+ PERMISSION_ALL);
+
+ // Register drawable
+ gameWrapper->RegisterDrawable(std::bind(&RocketStats::Render, this, std::placeholders::_1));
+
+ // Hook on Event
+ gameWrapper->HookEvent("Function GameEvent_TA.Countdown.BeginState", bind(&RocketStats::GameStart, this, std::placeholders::_1));
+ gameWrapper->HookEvent("Function TAGame.GameEvent_Soccar_TA.EventMatchEnded", bind(&RocketStats::GameEnd, this, std::placeholders::_1));
+ gameWrapper->HookEvent("Function CarComponent_Boost_TA.Active.BeginState", bind(&RocketStats::OnBoostStart, this, std::placeholders::_1));
+ gameWrapper->HookEvent("Function CarComponent_Boost_TA.Active.EndState", bind(&RocketStats::OnBoostEnd, this, std::placeholders::_1));
+ gameWrapper->HookEvent("Function TAGame.GameEvent_TA.Destroyed", bind(&RocketStats::GameDestroyed, this, std::placeholders::_1));
+
+ WriteInFile("RocketStats_Div.txt", "");
+ WriteInFile("RocketStats_Win.txt", "0");
+ WriteInFile("RocketStats_Streak.txt", "0");
+ WriteInFile("RocketStats_Loose.txt", "0");
+ WriteInFile("RocketStats_MMRChange.txt", "0");
+ WriteInFile("RocketStats_MMR.txt", "0");
+ WriteInFile("RocketStats_Rank.txt", "");
+ WriteInFile("RocketStats_GameMode.txt", "");
+ WriteInFile("RocketStats_images/BoostState.txt", "-1");
+
+ InitRank();
+
+ // Register Cvars
+ cvarManager->registerCvar("RS_Use_v1", "0", "Use the v1 overlay", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_Use_v2", "0", "Use the v2 overlay", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_ig", "1", "Display information panel", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_hide_overlay_ig", "0", "Hide overlay while in-game", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_mmr", "1", "Display the current MMR", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_wins", "1", "Display the wins on the current game mode", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_losses", "1", "Display the losses on the current game mode", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_streak", "1", "Display the streak on the current game mode", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_rank", "1", "Display the rank on the current game mode", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_disp_gamemode", "1", "Display the current game mode", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_enable_float", "0", "Enable floating point for MMR (OBS only)", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_x_position", "0.700", "Overlay X position", true, true, 0, true, 1.0f);
+ cvarManager->registerCvar("RS_y_position", "0.575", "Overlay Y position", true, true, 0, true, 1.0f);
+ cvarManager->registerCvar("RS_scale", "1", "Overlay scale", true, true, 0, true, 10);
+ cvarManager->registerCvar("RocketStats_stop_boost", "1", "Stop Boost animation", true, true, 0, true, 1);
+ cvarManager->registerCvar("RS_session", "0", "Display session information instead of game mode", true, true, 0, true, 1, true);
+}
+
+void RocketStats::onUnload() {}
+#pragma endregion
+
+#pragma region GameMgmt
+void RocketStats::GameStart(std::string eventName)
+{
+ if (!gameWrapper->IsInOnlineGame() || isGameStarted)
+ return;
+
+ cvarManager->log("===== GameStart =====");
+ CarWrapper me = gameWrapper->GetLocalCar();
+ if (me.IsNull())
+ return;
+
+ PriWrapper mePRI = me.GetPRI();
+ if (mePRI.IsNull())
+ return;
+
+ TeamInfoWrapper myTeam = mePRI.GetTeam();
+ if (myTeam.IsNull())
+ return;
+
+ MMRWrapper mmrw = gameWrapper->GetMMRWrapper();
+ currentPlaylist = mmrw.GetCurrentPlaylist();
+ SkillRank playerRank = mmrw.GetPlayerRank(gameWrapper->GetUniqueID(), currentPlaylist);
+ cvarManager->log(std::to_string(currentPlaylist) + " -> " + GetPlaylistName(currentPlaylist));
+
+ writeGameMode();
+ writeMMRChange();
+ writeWin();
+ writeStreak();
+ writeLosses();
+ writeMMR();
+
+ // Get TeamNum
+ myTeamNum = myTeam.GetTeamNum();
+
+ // Set Game Started
+ isGameStarted = true;
+ isGameEnded = false;
+
+ UpdateMMR(gameWrapper->GetUniqueID());
+ WriteInFile("RocketStats_images/BoostState.txt", std::to_string(0));
+}
+
+void RocketStats::GameEnd(std::string eventName)
+{
+ if (gameWrapper->IsInOnlineGame() && myTeamNum != -1)
+ {
+ cvarManager->log("===== GameEnd =====");
+ ServerWrapper server = gameWrapper->GetOnlineGame();
+ TeamWrapper winningTeam = server.GetGameWinner();
+ if (winningTeam.IsNull())
+ return;
+
+ int teamnum = winningTeam.GetTeamNum();
+
+ // Game as ended
+ isGameEnded = true;
+
+ MMRWrapper mw = gameWrapper->GetMMRWrapper();
+
+ if (myTeamNum == winningTeam.GetTeamNum())
+ {
+ cvarManager->log("===== Game Won =====");
+ // On Win, Increase streak and Win Number
+ stats[currentPlaylist].win++;
+ session.win++;
+
+ if (stats[currentPlaylist].streak < 0)
+ {
+ session.streak = 1;
+ stats[currentPlaylist].streak = 1;
+ }
+ else
+ {
+ session.streak += 1;
+ stats[currentPlaylist].streak++;
+ }
+
+ writeWin();
+ }
+ else
+ {
+ cvarManager->log("===== Game Lost =====");
+ // On Loose, Increase loose Number and decrease streak
+ stats[currentPlaylist].losses++;
+ session.losses++;
+ if (stats[currentPlaylist].streak > 0)
+ {
+ session.streak = -1;
+ stats[currentPlaylist].streak = -1;
+ }
+ else
+ {
+ session.streak--;
+ stats[currentPlaylist].streak--;
+ }
+
+ writeLosses();
+ }
+
+ writeStreak();
+
+ // Reset myTeamNum security
+ myTeamNum = -1;
+
+ WriteInFile("RocketStats_images/BoostState.txt", std::to_string(-1));
+
+ gameWrapper->SetTimeout([&](GameWrapper *gameWrapper)
+ { UpdateMMR(gameWrapper->GetUniqueID()); },
+ 3.0F);
+ }
+}
+
+void RocketStats::GameDestroyed(std::string eventName)
+{
+ cvarManager->log("===== GameDestroyed =====");
+ // Check if Game Ended, if not, RAGE QUIT or disconnect
+ if (isGameStarted == true && isGameEnded == false)
+ {
+ session.losses++;
+ stats[currentPlaylist].losses++;
+ if (stats[currentPlaylist].streak > 0)
+ {
+ session.streak = 0;
+ stats[currentPlaylist].streak = -1;
+ }
+ else
+ {
+ session.streak--;
+ stats[currentPlaylist].streak--;
+ }
+
+ writeStreak();
+ writeLosses();
+ }
+ isGameEnded = true;
+ isGameStarted = false;
+ WriteInFile("RocketStats_images/BoostState.txt", std::to_string(-1));
+}
+#pragma endregion
+
+#pragma region StatsMgmt
+void RocketStats::UpdateMMR(UniqueIDWrapper id)
+{
+ cvarManager->log("===== updateMMR =====");
+
+ if (id.GetIdString() != gameWrapper->GetUniqueID().GetIdString()) {
+ cvarManager->log("not the user");
+ return;
+ }
+
+ if (currentPlaylist == 0)
+ {
+ cvarManager->log("Invalid playlist id. Have you just opened the game ?");
+ return;
+ }
+
+ MMRWrapper mmrw = gameWrapper->GetMMRWrapper();
+ float mmr = mmrw.GetPlayerMMR(id, currentPlaylist);
+ SkillRank playerRank = mmrw.GetPlayerRank(id, currentPlaylist);
+
+ if (stats[currentPlaylist].isInit == false)
+ {
+ stats[currentPlaylist].myMMR = mmr;
+ stats[currentPlaylist].isInit = true;
+ }
+ stats[currentPlaylist].MMRChange = stats[currentPlaylist].MMRChange + (mmr - stats[currentPlaylist].myMMR);
+ stats[currentPlaylist].myMMR = mmr;
+
+ MajRank(currentPlaylist, mmrw.IsRanked(currentPlaylist), stats[currentPlaylist].myMMR, playerRank);
+ SessionStats();
+ writeMMR();
+ writeMMRChange();
+}
+
+void RocketStats::SessionStats()
+{
+ Stats tmp;
+
+ for (auto it = playlistName.begin(); it != playlistName.end(); it++)
+ {
+ tmp.MMRChange += stats[it->first].MMRChange;
+ tmp.win += stats[it->first].win;
+ tmp.losses += stats[it->first].losses;
+ }
+
+ session.myMMR = stats[currentPlaylist].myMMR;
+ session.MMRChange = tmp.MMRChange;
+ session.win = tmp.win;
+ session.losses = tmp.losses;
+}
+
+void RocketStats::ResetStats()
+{
+ for (auto &kv : stats)
+ {
+ kv.second = Stats();
+ }
+ session = Stats();
+ WriteInFile("RocketStats_Win.txt", std::to_string(0));
+ WriteInFile("RocketStats_Streak.txt", std::to_string(0));
+ WriteInFile("RocketStats_Loose.txt", std::to_string(0));
+ WriteInFile("RocketStats_MMRChange.txt", std::to_string(0));
+ WriteInFile("RocketStats_MMR.txt", std::to_string(0));
+ WriteInFile("RocketStats_Rank.txt", "");
+ WriteInFile("RocketStats_Div.txt", "");
+ WriteInFile("RocketStats_GameMode.txt", "");
+
+ InitRank();
+}
+#pragma endregion
+
+#pragma region BoostMgmt
+void RocketStats::OnBoostStart(std::string eventName)
+{
+ cvarManager->log("boostStart");
+ // Check if boost enabled in options
+ bool IsBoostEnabled = cvarManager->getCvar("RocketStats_stop_boost").getBoolValue();
+ if (!IsBoostEnabled || gameWrapper->IsInReplay() || isBoosting)
+ return;
+
+ CarWrapper cWrap = gameWrapper->GetLocalCar();
+
+ if (!cWrap.IsNull())
+ {
+ BoostWrapper bWrap = cWrap.GetBoostComponent();
+
+ if (!bWrap.IsNull() && bWrap.GetbActive() == 1 && !isBoosting)
+ {
+ isBoosting = true;
+ WriteInFile("RocketStats_images/BoostState.txt", std::to_string(1));
+ }
+ }
+
+ return;
+}
+
+void RocketStats::OnBoostEnd(std::string eventName)
+{
+ cvarManager->log("boostEnd");
+ // Check if boost enabled in options
+ bool IsBoostEnabled = cvarManager->getCvar("RocketStats_stop_boost").getBoolValue();
+ if (!IsBoostEnabled || gameWrapper->IsInReplay() || !isBoosting)
+ return;
+
+ CarWrapper cWrap = gameWrapper->GetLocalCar();
+
+ if (!cWrap.IsNull())
+ {
+ BoostWrapper bWrap = cWrap.GetBoostComponent();
+
+ if (!bWrap.IsNull() && bWrap.GetbActive() == 0 && isBoosting)
+ {
+ isBoosting = false;
+ WriteInFile("RocketStats_images/BoostState.txt", std::to_string(0));
+ }
+ }
+ return;
+}
+
+// Act as toggle
+// void RocketStats::StopBoost() {}
+#pragma endregion
+
+#pragma region Rank / Div
+void RocketStats::InitRank()
+{
+ lastGameMode = 0;
+ currentGameMode = 0;
+ currentMMR = 0;
+ currentRank = "norank";
+ currentDivision = "nodiv";
+ lastRank = "norank";
+
+ // std::string _value = "";
+
+ // WriteInFile("RocketStats_images/rank.html", _value);
+}
+
+void RocketStats::MajRank(int _gameMode, bool isRanked, float _currentMMR, SkillRank playerRank)
+{
+ currentGameMode = _gameMode;
+ currentMMR = _currentMMR;
+ currentTier = playerRank.Tier;
+
+ if (isRanked)
+ {
+ if (currentGameMode != 34 && playerRank.MatchesPlayed < 10)
+ {
+ currentRank = "Placement: " + std::to_string(playerRank.MatchesPlayed) + "/10";
+ currentDivision = "";
+ }
+ else
+ {
+ currentRank = GetRank(playerRank.Tier);
+ currentDivision = "Div. " + std::to_string(playerRank.Division + 1);
+ WriteInFile("RocketStats_Div.txt", currentDivision);
+ }
+
+ if (currentRank != lastRank)
+ {
+ // std::string _value = "";
+
+ // WriteInFile("RocketStats_images/rank.html", _value);
+ WriteInFile("RocketStats_Rank.txt", currentRank);
+ }
+ }
+ else
+ {
+ currentRank = GetPlaylistName(currentGameMode);
+ currentDivision = "";
+
+ // std::string _value = "";
+
+ // WriteInFile("RocketStats_images/rank.html", _value);
+ WriteInFile("RocketStats_Rank.txt", currentRank);
+ }
+}
+#pragma endregion
+
+#pragma region OverlayMgmt
+void RocketStats::DisplayRank(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, float scale, bool showText)
+{
+ if (currentTier >= rank_nb)
+ {
+ currentTier = 0;
+ }
+ std::shared_ptr image = rank[currentTier].image;
+
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(imagePos);
+ if (image->IsLoadedForCanvas())
+ canvas.DrawTexture(image.get(), 0.5f * scale);
+
+ if (showText)
+ {
+ std::string tmpRank = currentRank;
+ replaceAll(tmpRank, "_", " ");
+ canvas.SetPosition(textPos_tmp);
+ if (currentDivision == "")
+ canvas.DrawString(tmpRank, 2.0f * scale, 2.0f * scale);
+ else
+ canvas.DrawString(tmpRank + " " + currentDivision, 2.0f * scale, 2.0f * scale);
+ }
+}
+void RocketStats::DisplayMMR(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage)
+{
+ std::string mmr = to_string_with_precision(current.myMMR, 2);
+ std::string change = to_string_with_precision(current.MMRChange, 2);
+
+ if (showImage)
+ {
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(imagePos);
+ if (crown->IsLoadedForCanvas())
+ canvas.DrawTexture(crown.get(), 0.5f * scale);
+ }
+
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(textPos_tmp);
+ if (current.MMRChange > 0)
+ change = "+" + change;
+ canvas.DrawString(mmr + " (" + change + ")", 2.0f * scale, 2.0f * scale);
+}
+void RocketStats::DisplayWins(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale)
+{
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(imagePos);
+ if (win->IsLoadedForCanvas())
+ canvas.DrawTexture(win.get(), 0.5f * scale);
+
+ canvas.SetColor(LinearColor{0, 255, 0, 255});
+ canvas.SetPosition(textPos_tmp);
+ canvas.DrawString(std::to_string(current.win), 2.0f * scale, 2.0f * scale);
+}
+void RocketStats::DisplayLoose(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale)
+{
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(imagePos);
+ if (loose->IsLoadedForCanvas())
+ canvas.DrawTexture(loose.get(), 0.5f * scale);
+
+ canvas.SetColor(LinearColor{255, 0, 0, 255});
+ canvas.SetPosition(textPos_tmp);
+ canvas.DrawString(std::to_string(current.losses), 2.0f * scale, 2.0f * scale);
+}
+void RocketStats::DisplayStreak(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage)
+{
+ if (showImage)
+ {
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(imagePos);
+ if (streak->IsLoadedForCanvas())
+ canvas.DrawTexture(streak.get(), 0.5f * scale);
+ }
+
+ canvas.SetColor(LinearColor{255, 255, 255, 255});
+ canvas.SetPosition(textPos_tmp);
+
+ if (current.streak < 0)
+ canvas.SetColor(LinearColor{255, 0, 0, 255});
+ else
+ canvas.SetColor(LinearColor{0, 255, 0, 255});
+
+ std::string streak = std::to_string(current.streak);
+ if (current.streak > 0)
+ streak = "+" + streak;
+
+ canvas.DrawString(streak, 2.0f * scale, 2.0f * scale);
+}
+
+void RocketStats::Render(CanvasWrapper canvas)
+{
+ bool RS_disp_ig = cvarManager->getCvar("RS_disp_ig").getBoolValue();
+ bool RS_hide_overlay_ig = cvarManager->getCvar("RS_hide_overlay_ig").getBoolValue();
+
+ if (!RS_disp_ig || isGameStarted && !isGameEnded && RS_hide_overlay_ig)
+ return;
+
+ bool RS_Use_v1 = cvarManager->getCvar("RS_Use_v1").getBoolValue();
+ bool RS_Use_v2 = cvarManager->getCvar("RS_Use_v2").getBoolValue();
+ bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
+ float RS_x_position = cvarManager->getCvar("RS_x_position").getFloatValue();
+ float RS_y_position = cvarManager->getCvar("RS_y_position").getFloatValue();
+ float RS_scale = cvarManager->getCvar("RS_scale").getFloatValue();
+ Stats current = (RS_session == true) ? session : stats[currentPlaylist];
+
+ if (RS_Use_v1)
+ {
+ std::vector RS_values = {
+ "RS_disp_gamemode",
+ "RS_disp_rank",
+ "RS_disp_mmr",
+ "RS_disp_wins",
+ "RS_disp_losses",
+ "RS_disp_streak",
+ };
+
+ unsigned int size = 0;
+ for (auto &it : RS_values)
+ {
+ bool tmp = cvarManager->getCvar(it).getBoolValue();
+ if (tmp)
+ size += 1;
+ if (it == "RS_disp_mmr")
+ size += 1;
+ }
+
+ // Draw box here
+ Vector2 drawLoc = {
+ int(canvas.GetSize().X * RS_x_position),
+ int(canvas.GetSize().Y * RS_y_position)};
+ Vector2 sizeBox = {
+ int(175 * RS_scale),
+ int((23 * size) * RS_scale)};
+ canvas.SetPosition(drawLoc);
+
+ // Set background color
+ canvas.SetColor(LinearColor{0, 0, 0, 150});
+ canvas.FillBox(sizeBox);
+
+ // Draw text
+ Vector2 textPos = {int(drawLoc.X + 10), int(drawLoc.Y + 10)};
+ for (auto &it : RS_values)
+ {
+ bool tmp = cvarManager->getCvar(it).getBoolValue();
+
+ if (tmp)
+ {
+ // Set the position
+ canvas.SetPosition(textPos);
+
+ // Set Color and Text for the value
+ if (it == "RS_disp_gamemode")
+ {
+ canvas.SetColor(LinearColor{180, 180, 180, 255});
+ canvas.DrawString(GetPlaylistName(currentPlaylist), RS_scale, RS_scale);
+ }
+ else if (it == "RS_disp_rank")
+ {
+ std::string tmpRank = currentRank;
+ if (currentTier >= rank_nb)
+ currentTier = 0;
+ replaceAll(tmpRank, "_", " ");
+ canvas.SetColor(LinearColor{180, 180, 180, 255});
+ if (currentDivision == "")
+ canvas.DrawString(tmpRank, RS_scale, RS_scale);
+ else
+ canvas.DrawString(tmpRank + " " + currentDivision, RS_scale, RS_scale);
+ }
+ else if (it == "RS_disp_mmr")
+ {
+ canvas.SetColor(LinearColor{180, 180, 180, 255});
+ std::string mmr = to_string_with_precision(current.myMMR, 2);
+ canvas.DrawString("MMR : " + mmr, RS_scale, RS_scale);
+
+ textPos.Y += int(20 * RS_scale);
+ canvas.SetPosition(textPos);
+
+ std::string mmrchange = to_string_with_precision(current.MMRChange, 2);
+ if (current.MMRChange >= 0)
+ {
+ canvas.SetColor(LinearColor{30, 224, 24, 255});
+ canvas.DrawString("MMRChange : +" + mmrchange, RS_scale, RS_scale);
+ }
+ else
+ {
+ canvas.SetColor(LinearColor{224, 24, 24, 255});
+ canvas.DrawString("MMRChange : " + mmrchange, RS_scale, RS_scale);
+ }
+ }
+ else if (it == "RS_disp_wins")
+ {
+ canvas.SetColor(LinearColor{30, 224, 24, 255});
+ canvas.DrawString("Win : " + std::to_string(current.win), RS_scale, RS_scale);
+ }
+ else if (it == "RS_disp_losses")
+ {
+ canvas.SetColor(LinearColor{224, 24, 24, 255});
+ canvas.DrawString("Losses : " + std::to_string(current.losses), RS_scale, RS_scale);
+ }
+ else if (it == "RS_disp_streak")
+ {
+ if (current.streak >= 0)
+ {
+ canvas.SetColor(LinearColor{30, 224, 24, 255});
+ canvas.DrawString("Streak : +" + std::to_string(current.streak), RS_scale, RS_scale);
+ }
+ else
+ {
+ canvas.SetColor(LinearColor{224, 24, 24, 255});
+ canvas.DrawString("Streak : " + std::to_string(current.streak), RS_scale, RS_scale);
+ }
+ }
+ // Increase Y position
+ textPos.Y += int(20 * RS_scale);
+ }
+ }
+ }
+ else if (RS_Use_v2)
+ {
+ auto canSize = canvas.GetSize();
+ Vector2 imagePos = {int(RS_x_position * canSize.X), int(RS_y_position * canSize.Y)};
+ Vector2 textPos_tmp = imagePos;
+
+ textPos_tmp.X += int(50 * RS_scale);
+ textPos_tmp.Y += int(10 * RS_scale);
+
+ // Display Rank
+ if (cvarManager->getCvar("RS_disp_rank").getBoolValue())
+ {
+ DisplayRank(canvas, imagePos, textPos_tmp, RS_scale, true);
+ imagePos.Y += int(50 * RS_scale);
+ textPos_tmp.Y += int(50 * RS_scale);
+ }
+
+ // Display MMR
+ if (cvarManager->getCvar("RS_disp_mmr").getBoolValue())
+ {
+ DisplayMMR(canvas, imagePos, textPos_tmp, current, RS_scale, true);
+ imagePos.Y += int(50 * RS_scale);
+ textPos_tmp.Y += int(50 * RS_scale);
+ }
+
+ // Display Win
+ if (cvarManager->getCvar("RS_disp_wins").getBoolValue())
+ {
+ DisplayWins(canvas, imagePos, textPos_tmp, current, RS_scale);
+ imagePos.Y += int(50 * RS_scale);
+ textPos_tmp.Y += int(50 * RS_scale);
+ }
+
+ // Display Loose
+ if (cvarManager->getCvar("RS_disp_losses").getBoolValue())
+ {
+ DisplayLoose(canvas, imagePos, textPos_tmp, current, RS_scale);
+ }
+
+ // Display Streak
+ if (cvarManager->getCvar("RS_disp_streak").getBoolValue())
+ {
+ textPos_tmp.X += int(75 * RS_scale);
+ textPos_tmp.Y -= int(25 * RS_scale);
+ DisplayStreak(canvas, imagePos, textPos_tmp, current, RS_scale, false);
+ }
+ }
+ else
+ {
+ const bool displayRank = cvarManager->getCvar("RS_disp_rank").getBoolValue();
+ const bool displayMMR = cvarManager->getCvar("RS_disp_mmr").getBoolValue();
+ const bool displayWins = cvarManager->getCvar("RS_disp_wins").getBoolValue();
+ const bool displayLosses = cvarManager->getCvar("RS_disp_losses").getBoolValue();
+ const bool displayStreak = cvarManager->getCvar("RS_disp_streak").getBoolValue();
+ int size = 0;
+
+ if (displayRank)
+ size += 70;
+ if (displayMMR)
+ size += 250;
+ if (displayWins)
+ size += 110;
+ if (displayLosses)
+ size += 110;
+ if (displayStreak)
+ size += 110;
+ if (displayWins || displayLosses || displayStreak)
+ size += 50;
+
+ auto canSize = canvas.GetSize();
+
+ // Draw box here
+ Vector2 backgroundPos = {int(RS_x_position * canSize.X), int(RS_y_position * canSize.Y)};
+ Vector2 sizeBox = {
+ int(size * RS_scale),
+ int(50 * RS_scale)};
+ canvas.SetPosition(backgroundPos);
+ canvas.SetColor(LinearColor{0, 0, 0, 255});
+ canvas.FillBox(sizeBox);
+
+ Vector2 imagePos = backgroundPos;
+ imagePos.X += int(30 * RS_scale);
+
+ Vector2 textPos_tmp = imagePos;
+ textPos_tmp.Y += int(10 * RS_scale);
+
+ // Display Rank
+ if (displayRank)
+ {
+ DisplayRank(canvas, imagePos, textPos_tmp, RS_scale, false);
+ imagePos.X += int(70 * RS_scale);
+ textPos_tmp.X += int(70 * RS_scale);
+ }
+
+ // Display MMR
+ if (displayMMR)
+ {
+ DisplayMMR(canvas, imagePos, textPos_tmp, current, RS_scale, false);
+ imagePos.X += int(250 * RS_scale);
+ textPos_tmp.X += int(250 * RS_scale);
+ }
+
+ // Adjust text postition for the rest with images
+ textPos_tmp.X += int(70 * RS_scale);
+
+ // Display Win
+ if (displayWins)
+ {
+ DisplayWins(canvas, imagePos, textPos_tmp, current, RS_scale);
+ imagePos.X += int(110 * RS_scale);
+ textPos_tmp.X += int(110 * RS_scale);
+ }
+
+ // Display Loose
+ if (displayLosses)
+ {
+ DisplayLoose(canvas, imagePos, textPos_tmp, current, RS_scale);
+ imagePos.X += int(110 * RS_scale);
+ textPos_tmp.X += int(110 * RS_scale);
+ }
+
+ // Display Streak
+ if (displayStreak)
+ {
+ DisplayStreak(canvas, imagePos, textPos_tmp, current, RS_scale, true);
+ }
+ }
+}
+#pragma endregion
+
+#pragma region File I / O
+void RocketStats::WriteInFile(std::string _filename, std::string _value)
+{
+ std::ofstream stream(gameWrapper->GetBakkesModPath().string() + "\\RocketStats\\" + _filename, std::ios::out | std::ios::trunc);
+
+ if (stream.is_open())
+ {
+ stream << _value;
+ stream.close();
+ }
+ else
+ {
+ cvarManager->log("Can't write to file: " + _filename);
+ cvarManager->log("Value to write was: " + _value);
+ }
+}
+
+void RocketStats::writeGameMode()
+{
+ WriteInFile("RocketStats_GameMode.txt", GetPlaylistName(currentPlaylist));
+}
+
+void RocketStats::writeMMR()
+{
+ std::string tmp;
+ if (cvarManager->getCvar("RS_enable_float").getBoolValue())
+ tmp = to_string_with_precision(stats[currentPlaylist].myMMR, 2);
+ else
+ tmp = std::to_string(int(stats[currentPlaylist].myMMR));
+ WriteInFile("RocketStats_MMR.txt", tmp);
+}
+void RocketStats::writeMMRChange()
+{
+ bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
+ Stats current = (RS_session == true) ? session : stats[currentPlaylist];
+
+ std::string tmp;
+ if (cvarManager->getCvar("RS_enable_float").getBoolValue())
+ tmp = to_string_with_precision(current.MMRChange, 2);
+ else
+ tmp = std::to_string(int(current.MMRChange));
+
+ if (current.MMRChange > 0)
+ WriteInFile("RocketStats_MMRChange.txt", "+" + tmp);
+ else
+ WriteInFile("RocketStats_MMRChange.txt", tmp);
+}
+
+void RocketStats::writeStreak()
+{
+ bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
+ Stats current = (RS_session == true) ? session : stats[currentPlaylist];
+
+ if (current.streak > 0)
+ WriteInFile("RocketStats_Streak.txt", "+" + std::to_string(current.streak));
+ else
+ WriteInFile("RocketStats_Streak.txt", std::to_string(current.streak));
+}
+void RocketStats::writeWin()
+{
+ bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
+ Stats current = (RS_session == true) ? session : stats[currentPlaylist];
+ WriteInFile("RocketStats_Win.txt", std::to_string(current.win));
+}
-namespace NS_RS {
- BAKKESMOD_PLUGIN(RocketStats, "Tracks matches results", plugin_version, 0)
-
- void RocketStats::onLoad()
- {
- // notifierToken = gameWrapper->GetMMRWrapper().RegisterMMRNotifier(std::bind(&RocketStats::UpdateMMR, this, std::placeholders::_1));
-
- LoadImgs();
-
- cvarManager->registerNotifier(
- "RocketStats_reset_stats",
- [this](std::vector params)
- { ResetStats(); },
- "Reset Stats",
- PERMISSION_ALL);
-
- cvarManager->registerNotifier(
- "RocketStats_reload_images",
- [this](std::vector params)
- { LoadImgs(); },
- "Reload images",
- PERMISSION_ALL);
-
- // Register drawable
- gameWrapper->RegisterDrawable(std::bind(&RocketStats::Render, this, std::placeholders::_1));
-
- // Hook on Event
- gameWrapper->HookEvent("Function GameEvent_TA.Countdown.BeginState", bind(&RocketStats::GameStart, this, std::placeholders::_1));
- gameWrapper->HookEvent("Function TAGame.GameEvent_Soccar_TA.EventMatchEnded", bind(&RocketStats::GameEnd, this, std::placeholders::_1));
- gameWrapper->HookEvent("Function CarComponent_Boost_TA.Active.BeginState", bind(&RocketStats::OnBoostStart, this, std::placeholders::_1));
- gameWrapper->HookEvent("Function CarComponent_Boost_TA.Active.EndState", bind(&RocketStats::OnBoostEnd, this, std::placeholders::_1));
- gameWrapper->HookEvent("Function TAGame.GameEvent_TA.Destroyed", bind(&RocketStats::GameDestroyed, this, std::placeholders::_1));
-
- WriteInFile("RocketStats_Div.txt", "");
- WriteInFile("RocketStats_Win.txt", "0");
- WriteInFile("RocketStats_Streak.txt", "0");
- WriteInFile("RocketStats_Loose.txt", "0");
- WriteInFile("RocketStats_MMRChange.txt", "0");
- WriteInFile("RocketStats_MMR.txt", "0");
- WriteInFile("RocketStats_Rank.txt", "");
- WriteInFile("RocketStats_GameMode.txt", "");
- WriteInFile("RocketStats_images/BoostState.txt", "-1");
-
- InitRank();
-
- // Register Cvars
- cvarManager->registerCvar("RS_Use_v1", "0", "Use the v1 overlay", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_Use_v2", "0", "Use the v2 overlay", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_ig", "1", "Display information panel", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_hide_overlay_ig", "0", "Hide overlay while in-game", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_mmr", "1", "Display the current MMR", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_wins", "1", "Display the wins on the current game mode", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_losses", "1", "Display the losses on the current game mode", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_streak", "1", "Display the streak on the current game mode", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_rank", "1", "Display the rank on the current game mode", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_disp_gamemode", "1", "Display the current game mode", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_enable_float", "0", "Enable floating point for MMR (OBS only)", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_x_position", "0.700", "Overlay X position", true, true, 0, true, 1.0f);
- cvarManager->registerCvar("RS_y_position", "0.575", "Overlay Y position", true, true, 0, true, 1.0f);
- cvarManager->registerCvar("RS_scale", "1", "Overlay scale", true, true, 0, true, 10);
- cvarManager->registerCvar("RocketStats_stop_boost", "1", "Stop Boost animation", true, true, 0, true, 1);
- cvarManager->registerCvar("RS_session", "0", "Display session information instead of game mode", true, true, 0, true, 1, true);
- }
-
- void RocketStats::onUnload() {}
-}
\ No newline at end of file
+void RocketStats::writeLosses()
+{
+ bool RS_session = cvarManager->getCvar("RS_session").getBoolValue();
+ Stats current = (RS_session == true) ? session : stats[currentPlaylist];
+ WriteInFile("RocketStats_Loose.txt", std::to_string(current.losses));
+}
+#pragma endregion
diff --git a/RocketStats/RocketStats.h b/RocketStats/RocketStats.h
index 219d3b5d..f50abf41 100644
--- a/RocketStats/RocketStats.h
+++ b/RocketStats/RocketStats.h
@@ -3,118 +3,120 @@
#include "bakkesmod/plugin/bakkesmodplugin.h"
#include "bakkesmod/plugin/pluginwindow.h"
-#include "Structs.h"
-
-#define replaceAll(str, from, to) while(replace(str, from, to));
-
-namespace NS_RS {
- constexpr auto plugin_version = "3.5";
-
- class RocketStats : public BakkesMod::Plugin::BakkesModPlugin/*, public BakkesMod::Plugin::PluginWindow*/
- {
- int currentPlaylist = 0;
- bool isGameEnded = false;
- bool isGameStarted = false;
- bool isBoosting = false;
-
- std::map stats;
- Stats session;
-
- //std::unique_ptr notifierToken;
-
- int myTeamNum = -1;
-
- int lastGameMode = 0;
- int currentGameMode = 0;
- float currentMMR = 100.0f;
- int currentTier = 0;
-
- std::string currentDivision;
- std::string currentRank;
- std::string lastRank;
-
- std::shared_ptr crown;
- std::shared_ptr win;
- std::shared_ptr loose;
- std::shared_ptr streak;
-
- int rank_nb = 23;
-
- //Plugin Load Routines
- virtual void onLoad();
- virtual void onUnload();
-
- // Utils
- std::string GetRank(int tierID);
- std::string GetPlaylistName(int playlistID);
- void LoadImgs();
- void LogImageLoadStatus(bool status, std::string imageName);
-
- // Game Hooks
- void GameStart(std::string eventName);
- void GameEnd(std::string eventName);
- void GameDestroyed(std::string eventName);
-
- // Stats mgmt
- void UpdateMMR(UniqueIDWrapper id);
- void SessionStats();
- void ResetStats();
-
- // Boost Hooks
- void OnBoostStart(std::string eventName);
- void OnBoostEnd(std::string eventName);
-
- // Rank / Div
- void InitRank();
- void MajRank(int _gameMode, bool isRanked, float _currentMMR, SkillRank playerRank);
-
- // Overlay mgmt
- void DisplayRank(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, float scale, bool showText);
- void DisplayMMR(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage);
- void DisplayWins(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale);
- void DisplayLoose(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale);
- void DisplayStreak(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage);
-
- // File I/O
- void WriteInFile(std::string _fileName, std::string _value);
- void writeGameMode();
- void writeMMR();
- void writeMMRChange();
- void writeStreak();
- void writeWin();
- void writeLosses();
-
- // Render
- void Render(CanvasWrapper canvas);
-
-
- t_ranks rank[23] = {
- {"Unranked", nullptr},
- {"Bronze_I", nullptr},
- {"Bronze_II", nullptr},
- {"Bronze_III", nullptr},
- {"Silver_I", nullptr},
- {"Silver_II", nullptr},
- {"Silver_III", nullptr},
- {"Gold_I", nullptr},
- {"Gold_II", nullptr},
- {"Gold_III", nullptr},
- {"Platinum_I", nullptr},
- {"Platinum_II", nullptr},
- {"Platinum_III", nullptr},
- {"Diamond_I", nullptr},
- {"Diamond_II", nullptr},
- {"Diamond_III", nullptr},
- {"Champion_I", nullptr},
- {"Champion_II", nullptr},
- {"Champion_III", nullptr},
- {"Grand_Champion_I", nullptr},
- {"Grand_Champion_II", nullptr},
- {"Grand_Champion_III", nullptr},
- {"Supersonic_Legend", nullptr},
- };
-
- const std::map playlistName = {
+struct Stats {
+ float myMMR = 100.0f;
+ float MMRChange = 0.0f;
+ int win = 0;
+ int losses = 0;
+ int streak = 0;
+ bool isInit = 0;
+};
+
+class RocketStats : public BakkesMod::Plugin::BakkesModPlugin
+{
+private:
+ std::shared_ptr enabled;
+
+public:
+ virtual void onLoad();
+ virtual void onUnload();
+
+ void LogImageLoadStatus(bool status, std::string imageName);
+ std::string GetRank(int tierID);
+ std::string GetPlaylistName(int playlistID);
+ void replaceAll(std::string& str, const std::string& from, const std::string& to);
+ void LoadImgs();
+
+ void GameStart(std::string eventName);
+ void GameEnd(std::string eventName);
+ void GameDestroyed(std::string eventName);
+
+ void UpdateMMR(UniqueIDWrapper id);
+ void SessionStats();
+ void ResetStats();
+
+ void OnBoostStart(std::string eventName);
+ void OnBoostEnd(std::string eventName);
+ //void StopBoost();
+
+
+ void InitRank();
+ void MajRank(int _gameMode, bool isRanked, float _currentMMR, SkillRank playerRank);
+
+ void DisplayRank(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, float scale, bool showText);
+ void DisplayMMR(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage);
+ void DisplayWins(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale);
+ void DisplayLoose(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale);
+ void DisplayStreak(CanvasWrapper canvas, Vector2 imagePos, Vector2 textPos_tmp, Stats current, float scale, bool showImage);
+ void Render(CanvasWrapper canvas);
+
+ void WriteInFile(std::string _fileName, std::string _value);
+ void writeGameMode();
+ void writeMMR();
+ void writeMMRChange();
+ void writeStreak();
+ void writeWin();
+ void writeLosses();
+
+ int currentPlaylist = 0;
+ bool isGameEnded = false;
+ bool isGameStarted = false;
+ bool isBoosting = false;
+
+ std::map stats;
+ Stats session;
+
+ //std::unique_ptr notifierToken;
+
+ int myTeamNum = -1;
+
+ int lastGameMode = 0;
+ int currentGameMode = 0;
+ float currentMMR = 100.0f;
+ int currentTier = 0;
+ std::string currentDivision;
+ std::string currentRank;
+ std::string lastRank;
+
+ std::shared_ptr crown;
+ std::shared_ptr win;
+ std::shared_ptr loose;
+ std::shared_ptr streak;
+
+ int rank_nb = 23;
+
+ typedef struct s_ranks {
+ std::string name;
+ std::shared_ptr image;
+ } t_ranks;
+
+ t_ranks rank[23] = {
+ {"Unranked", nullptr},
+ {"Bronze_I", nullptr},
+ {"Bronze_II", nullptr},
+ {"Bronze_III", nullptr},
+ {"Silver_I", nullptr},
+ {"Silver_II", nullptr},
+ {"Silver_III", nullptr},
+ {"Gold_I", nullptr},
+ {"Gold_II", nullptr},
+ {"Gold_III", nullptr},
+ {"Platinum_I", nullptr},
+ {"Platinum_II", nullptr},
+ {"Platinum_III", nullptr},
+ {"Diamond_I", nullptr},
+ {"Diamond_II", nullptr},
+ {"Diamond_III", nullptr},
+ {"Champion_I", nullptr},
+ {"Champion_II", nullptr},
+ {"Champion_III", nullptr},
+ {"Grand_Champion_I", nullptr},
+ {"Grand_Champion_II", nullptr},
+ {"Grand_Champion_III", nullptr},
+ {"Supersonic_Legend", nullptr},
+ };
+
+ const std::map playlistName = {
{1, "Duel"},
{2, "Doubles"},
{3, "Standard"},
@@ -162,6 +164,5 @@ namespace NS_RS {
{47, "Super Cube"},
{48, "Tactical Rumble"},
{49, "Spring Loaded"}
- };
};
-}
\ No newline at end of file
+};
diff --git a/RocketStats/RocketStats.vcxproj b/RocketStats/RocketStats.vcxproj
index e1bf6a2d..614eaeef 100644
--- a/RocketStats/RocketStats.vcxproj
+++ b/RocketStats/RocketStats.vcxproj
@@ -1,5 +1,5 @@
-
+
Release
@@ -7,10 +7,11 @@
- 16.0
- {3a9a96b9-4537-4b8e-8164-181a6b3c8b7f}
+ 15.0
+ {99C07F6D-C7AD-499D-B9D8-880EEDF0A2D0}
RocketStats
10.0
+ RocketStats
@@ -18,7 +19,7 @@
false
v142
true
- Unicode
+ MultiByte
@@ -27,78 +28,40 @@
-
-
- false
- $(ProjectDir)plugins\
- $(ProjectDir)build\$(Configuration)\
-
+
Level3
+ MaxSpeed
true
true
true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- Use
- pch.h
+ $(BAKKESMOD)\bakkesmodsdk\include;%(AdditionalIncludeDirectories)
+ true
MultiThreaded
stdcpp17
-
-
- Console
true
true
- true
+ $(BAKKESMOD)\bakkesmodsdk\lib;%(AdditionalLibraryDirectories)
+
+ "$(BAKKESMOD)\bakkesmodsdk\bakkesmod-patch.exe" $(TargetPath)
+copy "$(SolutionDir)settings\$(ProjectName).set" "$(BAKKESMOD)\plugins\settings\$(ProjectName).set"
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/RocketStats/RocketStats.vcxproj.filters b/RocketStats/RocketStats.vcxproj.filters
index 23010f2b..2a2cffd3 100644
--- a/RocketStats/RocketStats.vcxproj.filters
+++ b/RocketStats/RocketStats.vcxproj.filters
@@ -1,141 +1,30 @@
-
+
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
+
{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
-
+
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
- {396e4dda-4fe2-4588-9756-a364a57aa8c1}
-
-
- {ae0c99c9-78de-41f1-8c8d-e6eb860af833}
-
-
- {d46c4711-0bdc-484c-bb4c-5526d80f7f5e}
-
+
+
+
+ Fichiers d%27en-tête
+
- Source Files
-
-
- Source Files
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- imgui\implementation
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
+ Fichiers sources
-
- Header Files
-
-
- Header Files
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- imgui\headers
-
-
- Header Files
-
+
\ No newline at end of file
diff --git a/RocketStats/RocketStats.vcxproj.user b/RocketStats/RocketStats.vcxproj.user
index 88a55094..790210aa 100644
--- a/RocketStats/RocketStats.vcxproj.user
+++ b/RocketStats/RocketStats.vcxproj.user
@@ -1,4 +1,7 @@
-
-
+
+
+
+ D:\Steam\steamapps\common\rocketleague\Binaries\Win64\bakkesmod
+
\ No newline at end of file
diff --git a/RocketStats/Structs.h b/RocketStats/Structs.h
deleted file mode 100644
index 58b30365..00000000
--- a/RocketStats/Structs.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include "pch.h"
-
-namespace NS_RS {
- struct Stats {
- float myMMR = 600.0f;
- float MMRChange = 0.0f;
- int win = 0;
- int losses = 0;
- int streak = 0;
- bool isInit = 0;
- };
-
- typedef struct s_ranks {
- std::string name;
- std::shared_ptr image;
- } t_ranks;
-}
\ No newline at end of file
diff --git a/RocketStats/pch.cpp b/RocketStats/pch.cpp
deleted file mode 100644
index 1d9f38c5..00000000
--- a/RocketStats/pch.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "pch.h"
diff --git a/RocketStats/pch.h b/RocketStats/pch.h
deleted file mode 100644
index 6507b680..00000000
--- a/RocketStats/pch.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-
-#define WIN32_LEAN_AND_MEAN
-#define _CRT_SECURE_NO_WARNINGS
-#include "bakkesmod/plugin/bakkesmodplugin.h"
-
-#include
-#include
-#include
-#include
-
-#include "utils/parser.h"
diff --git a/RocketStats/settings/rocketstats.set b/settings/rocketstats.set
similarity index 100%
rename from RocketStats/settings/rocketstats.set
rename to settings/rocketstats.set