Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions InGameStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using UnityEngine.UI;
using TMPro;
using System.Reflection;
using UnityEngine.Localization;
using UnityEngine.Localization.Tables;

namespace InGameStats;

Expand Down Expand Up @@ -214,11 +216,15 @@ private void Update() {
// Update the stat texts with the current values
foreach (StatType stat in enabledStats)
if (_statTexts.TryGetValue(stat, out TextMeshProUGUI? text) && text != null) {
string titleString =
InGameStatsUtils.statDisplayNames.TryGetValue(stat, out LocalizedString title)
? title.GetLocalizedString()
: stat.ToString();
try {
string value = GetStatValue(stat);
text.text = $"{InGameStatsUtils.statDisplayNames[stat]}: {value}";
text.text = $"{titleString}: {value}";
} catch {
text.text = $"{InGameStatsUtils.statDisplayNames[stat]}: N/A";
text.text = $"{titleString}: N/A";
}
}
}
Expand Down Expand Up @@ -322,6 +328,9 @@ public void CreateStatUI() {
}
}

internal static LocalizedString failedString = InGameStatsUtils.TryGetLocalizedString("Failed", "Failed");
internal static LocalizedString successString = InGameStatsUtils.TryGetLocalizedString("Yes", "Yes");

/// <summary>
/// Gets the value of a specific stat based on the provided StatType.
/// </summary>
Expand All @@ -347,11 +356,11 @@ private string GetStatValue(StatType stat) {
StatType.Shard => RunHandler.isEndless ? "Endless" : (RunHandler.RunData.shardID + 1).ToString(),
StatType.Level => InGameStatsUtils.GetLevelStats(),
StatType.Seed => RunHandler.RunData.currentSeed.ToString(),
StatType.NoDeath => _noDeath ? "Yes" : "No",
StatType.NoItems => _noItems ? "Yes" : "No",
StatType.NoHit => _noHit ? "Yes" : "No",
StatType.OnlyPerfectLanding => _onlyPerfectLanding ? "Yes" : "No",
StatType.OnlySRanks => _onlySRanks ? "Yes" : "No",
StatType.NoDeath => (_noDeath ? successString : failedString).GetLocalizedString(),
StatType.NoItems => (_noItems ? successString : failedString).GetLocalizedString(),
StatType.NoHit => (_noHit ? successString : failedString).GetLocalizedString(),
StatType.OnlyPerfectLanding => (_onlyPerfectLanding ? successString : failedString).GetLocalizedString(),
StatType.OnlySRanks => (_onlySRanks ? successString : failedString).GetLocalizedString(),
_ => "N/A"
};
}
Expand Down
6 changes: 6 additions & 0 deletions InGameStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
<DebugType>none</DebugType>
<Version>1.11</Version>
</PropertyGroup>

<ItemGroup>
<None Update="InGameStats.localization.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Loading