Gameplay Stats Tweaks (#2379)

* persist stat tracker across sessions

* fix tab spaces

* configurable gameplay stats display

* streamline to use AddWindow method
This commit is contained in:
tcpowell 2023-01-25 17:43:50 -05:00 committed by GitHub
commit ec4cee787c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,6 +120,9 @@ void DrawStatsTracker(bool& open) {
return; return;
} }
bool showTimestamps = (CVarGetInteger("gGameplayStatsMode", 0) <= 1);
bool showCounts = ( (CVarGetInteger("gGameplayStatsMode", 0) == 0) || (CVarGetInteger("gGameplayStatsMode", 0) == 2) );
u32 totalTimer = GAMEPLAYSTAT_TOTAL_TIME; u32 totalTimer = GAMEPLAYSTAT_TOTAL_TIME;
u32 enemiesDefeated = 0; u32 enemiesDefeated = 0;
u32 ammoUsed = 0; u32 ammoUsed = 0;
@ -168,12 +171,18 @@ void DrawStatsTracker(bool& open) {
ImGui::EndTable(); ImGui::EndTable();
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f }); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f });
ImGui::BeginTable("gameStatsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV); ImGui::BeginTable("gameStatsTable", (showTimestamps && showCounts) ? 2 : 1, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV);
if (showTimestamps) {
ImGui::TableSetupColumn("Timestamps", ImGuiTableColumnFlags_WidthStretch, 200.0f); ImGui::TableSetupColumn("Timestamps", ImGuiTableColumnFlags_WidthStretch, 200.0f);
}
if (showCounts) {
ImGui::TableSetupColumn("Counts", ImGuiTableColumnFlags_WidthStretch, 200.0f); ImGui::TableSetupColumn("Counts", ImGuiTableColumnFlags_WidthStretch, 200.0f);
}
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
ImGui::TableNextRow(); ImGui::TableNextRow();
if (showTimestamps) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
// Display chronological timestamps of items obtained and bosses defeated // Display chronological timestamps of items obtained and bosses defeated
@ -183,7 +192,9 @@ void DrawStatsTracker(bool& open) {
DisplayTimeHHMMSS(timestampDisplay[i].time, timestampDisplay[i].name, timestampDisplay[i].color); DisplayTimeHHMMSS(timestampDisplay[i].time, timestampDisplay[i].name, timestampDisplay[i].color);
} }
} }
}
if (showCounts) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
DisplayStat("Enemies Defeated: ", enemiesDefeated); DisplayStat("Enemies Defeated: ", enemiesDefeated);
@ -330,10 +341,18 @@ void DrawStatsTracker(bool& open) {
ImGui::TreePop(); ImGui::TreePop();
} }
} }
}
ImGui::PopStyleVar(1); ImGui::PopStyleVar(1);
ImGui::EndTable(); ImGui::EndTable();
const char* gameplayStatsModeOptions[3] = { "Both", "Timestamps", "Counts"};
ImGui::Text("Display Mode");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
UIWidgets::EnhancementCombobox("gGameplayStatsMode", gameplayStatsModeOptions, 3, 0);
ImGui::Text("Note: Gameplay stats are saved to the current file and will be\nlost if you quit without saving."); ImGui::Text("Note: Gameplay stats are saved to the current file and will be\nlost if you quit without saving.");
ImGui::End(); ImGui::End();
@ -482,7 +501,7 @@ void SetupDisplayColors() {
} }
void InitStatTracker() { void InitStatTracker() {
SohImGui::AddWindow("Enhancements", "Gameplay Stats", DrawStatsTracker); SohImGui::AddWindow("Enhancements", "Gameplay Stats", DrawStatsTracker, CVarGetInteger("gGameplayStatsEnabled", 0) == 1);
SetupDisplayNames(); SetupDisplayNames();
SetupDisplayColors(); SetupDisplayColors();
} }