This commit is contained in:
aMannus 2024-05-11 05:34:09 -03:00 committed by GitHub
commit 57baba3fd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 59 additions and 0 deletions

View File

@ -126,6 +126,8 @@ u32 areasSpoiled = 0;
bool showVOrMQ;
s8 areaChecksGotten[RCAREA_INVALID]; //| "Kokiri Forest (4/9)"
s8 areaCheckTotals[RCAREA_INVALID];
uint16_t totalChecks = 0;
uint16_t totalChecksGotten = 0;
bool optCollapseAll; // A bool that will collapse all checks once
bool optExpandAll; // A bool that will expand all checks once
RandomizerCheck lastLocationChecked = RC_UNKNOWN_CHECK;
@ -246,6 +248,24 @@ void TrySetAreas() {
}
}
void CalculateTotals() {
totalChecks = 0;
totalChecksGotten = 0;
for (uint8_t i = 0; i < RCAREA_INVALID; i++) {
totalChecks += areaCheckTotals[i];
totalChecksGotten += areaChecksGotten[i];
}
}
uint16_t GetTotalChecks() {
return totalChecks;
}
uint16_t GetTotalChecksGotten() {
return totalChecksGotten;
}
void RecalculateAreaTotals() {
for (auto [rcArea, rcObjects] : checksByArea) {
if (rcArea == RCAREA_INVALID) {
@ -395,6 +415,8 @@ void ClearAreaChecksAndTotals() {
areaChecksGotten[rcArea] = 0;
areaCheckTotals[rcArea] = 0;
}
totalChecks = 0;
totalChecksGotten = 0;
}
void SetShopSeen(uint32_t sceneNum, bool prices) {
@ -940,6 +962,10 @@ void CheckTrackerWindow::DrawElement() {
UIWidgets::PaddedSeparator();
ImGui::Text("Total Checks: %d / %d", totalChecksGotten, totalChecks);
UIWidgets::PaddedSeparator();
//Checks Section Lead-in
ImGui::TableNextRow();
ImGui::TableNextColumn();
@ -1317,6 +1343,8 @@ void UpdateOrdering(RandomizerCheckArea rcArea) {
if(checksByArea.contains(rcArea)) {
std::sort(checksByArea.find(rcArea)->second.begin(), checksByArea.find(rcArea)->second.end(), CompareChecks);
}
CalculateTotals();
}
bool IsEoDCheck(RandomizerCheckType type) {

View File

@ -51,6 +51,8 @@ bool IsCheckShuffled(RandomizerCheckObject check);
void InitTrackerData(bool isDebug);
RandomizerCheckArea GetCheckArea();
void UpdateCheck(uint32_t, RandomizerCheckTrackerData);
uint16_t GetTotalChecks();
uint16_t GetTotalChecksGotten();
bool IsAreaSpoiled(RandomizerCheckArea rcArea);
void SetAreaSpoiled(RandomizerCheckArea rcArea);
} // namespace CheckTracker

View File

@ -1,4 +1,5 @@
#include "randomizer_item_tracker.h"
#include "randomizer_check_tracker.h"
#include "../../util.h"
#include "../../OTRGlobals.h"
#include "../../UIWidgets.hpp"
@ -268,6 +269,11 @@ typedef enum {
SECTION_DISPLAY_EXTENDED_SEPARATE
} ItemTrackerExtendedDisplayType;
typedef enum {
SECTION_DISPLAY_MINIMAL_HIDDEN,
SECTION_DISPLAY_MINIMAL_SEPARATE
} ItemTrackerMinimalDisplayType;
struct ItemTrackerNumbers {
int currentCapacity;
int maxCapacity;
@ -766,6 +772,16 @@ void DrawNotes(bool resizeable = false) {
ImGui::EndGroup();
}
void DrawTotalChecks() {
uint16_t totalChecks = CheckTracker::GetTotalChecks();
uint16_t totalChecksGotten = CheckTracker::GetTotalChecksGotten();
ImGui::BeginGroup();
ImGui::SetWindowFontScale(2.5);
ImGui::Text("Checks: %d/%d", totalChecksGotten, totalChecks);
ImGui::EndGroup();
}
// Windowing stuff
ImVec4 ChromaKeyBackground = { 0, 0, 0, 0 }; // Float value, 1 = 255 in rgb value.
void BeginFloatingWindows(std::string UniqueName, ImGuiWindowFlags flags = 0) {
@ -1109,6 +1125,14 @@ void ItemTrackerWindow::DrawElement() {
DrawNotes(true);
EndFloatingWindows();
}
if (CVarGetInteger("gTrackers.ItemTracker.TotalChecks.DisplayType", SECTION_DISPLAY_MINIMAL_HIDDEN) ==
SECTION_DISPLAY_MINIMAL_SEPARATE) {
ImGui::SetNextWindowSize(ImVec2(400, 300), ImGuiCond_FirstUseEver);
BeginFloatingWindows("Total Checks");
DrawTotalChecks();
EndFloatingWindows();
}
}
}
@ -1120,6 +1144,7 @@ static const char* displayModes[2] = { "Always", "Combo Button Hold" };
static const char* buttons[14] = { "A", "B", "C-Up", "C-Down", "C-Left", "C-Right", "L", "Z", "R", "Start", "D-Up", "D-Down", "D-Left", "D-Right" };
static const char* displayTypes[3] = { "Hidden", "Main Window", "Separate" };
static const char* extendedDisplayTypes[4] = { "Hidden", "Main Window", "Misc Window", "Separate" };
static const char* minimalDisplayTypes[2] = { "Hidden", "Separate" };
void ItemTrackerSettingsWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(733, 472), ImGuiCond_FirstUseEver);
@ -1253,6 +1278,10 @@ void ItemTrackerSettingsWindow::DrawElement() {
UIWidgets::Spacer(0);
if (UIWidgets::LabeledRightAlignedEnhancementCombobox("Total Checks", "gTrackers.ItemTracker.TotalChecks.DisplayType", minimalDisplayTypes, SECTION_DISPLAY_MINIMAL_HIDDEN)) {
shouldUpdateVectors = true;
}
ImGui::PopStyleVar(1);
ImGui::EndTable();