From 9df42061e85c4ee4a6b29541d1c9aeb23380495d Mon Sep 17 00:00:00 2001 From: Kittenji <41535779+ChrisFeline@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:03:35 -0400 Subject: [PATCH] Add IsOptedIn to stats. --- Localization/Language/en-US.json | 2 ++ Models/Stats/StatsData.cs | 1 + Models/Stats/ToNStats.cs | 5 +++++ Utils/LogParser/ToNGameState.cs | 2 ++ Windows/StatsWindow.cs | 4 ++++ 5 files changed, 14 insertions(+) diff --git a/Localization/Language/en-US.json b/Localization/Language/en-US.json index 5e38c9e..7a8c99e 100644 --- a/Localization/Language/en-US.json +++ b/Localization/Language/en-US.json @@ -308,6 +308,8 @@ "STATS.LABEL_PLAYERSONLINE.TT": "Represents the amount of players in the instance.", "STATS.LABEL_ITEMNAME": "Item Name", "STATS.LABEL_ITEMNAME.TT": "The name of the current item held.", + "STATS.LABEL_ISOPTEDIN": "Is Opted In", + "STATS.LABEL_ISOPTEDIN.TT": "True if the player is opted-in onto the game. This means the player is outside the respawn zone.", "STATS.LABEL_ROUNDSTUNS": "Round Stuns", "STATS.LABEL_ROUNDSTUNS.TT": "Amount of times you have stunned a Terror in the round.", diff --git a/Models/Stats/StatsData.cs b/Models/Stats/StatsData.cs index 0e6e39b..943df6c 100644 --- a/Models/Stats/StatsData.cs +++ b/Models/Stats/StatsData.cs @@ -38,6 +38,7 @@ internal class StatsRound : StatsBase { internal class StatsLobby : StatsData { public int PlayersOnline { get; internal set; } = 0; + public bool IsOptedIn { get; internal set; } = false; // Player data public string DisplayName { get; internal set; } = "Unknown"; diff --git a/Models/Stats/ToNStats.cs b/Models/Stats/ToNStats.cs index e70750d..526b158 100644 --- a/Models/Stats/ToNStats.cs +++ b/Models/Stats/ToNStats.cs @@ -137,6 +137,11 @@ public static void AddDamage(int damage, bool ready) { if (ready) Add(KEY_DAMAGE, damage); } + const string KEY_OPTEDIN_PLAYERS = nameof(StatsLobby.IsOptedIn); + public static void AddOptedIn(bool optedIn) { + Set(KEY_OPTEDIN_PLAYERS, optedIn); + } + const string KEY_ONLINE_PLAYERS = nameof(StatsLobby.PlayersOnline); public static void AddPlayerCount(int players) { Set(KEY_ONLINE_PLAYERS, players); diff --git a/Utils/LogParser/ToNGameState.cs b/Utils/LogParser/ToNGameState.cs index 148048b..cd5dec4 100644 --- a/Utils/LogParser/ToNGameState.cs +++ b/Utils/LogParser/ToNGameState.cs @@ -89,6 +89,8 @@ public static void SetAlive(bool isAlive) { public static void SetOptedIn(bool isOptedIn) { IsOptedIn = isOptedIn; + + StatsWindow.SetOptedIn(IsOptedIn); LilOSC.SetDirty(); WebSocketAPI.SendValue("OPTED_IN", IsOptedIn); diff --git a/Windows/StatsWindow.cs b/Windows/StatsWindow.cs index 50c610b..0939bd3 100644 --- a/Windows/StatsWindow.cs +++ b/Windows/StatsWindow.cs @@ -80,6 +80,10 @@ internal static void SetPageCount(int pages) { ToNStats.AddPageCount(pages); RefreshTable(); } + internal static void SetOptedIn(bool optedIn) { + ToNStats.AddOptedIn(optedIn); + RefreshTable(); + } internal static void SetPlayerCount(int playerCount) { ToNStats.AddPlayerCount(playerCount); RefreshTable();