Added option to Enable Available Checks.

This commit is contained in:
Anthony Stewart 2025-03-21 23:57:15 -05:00
commit 7020f3a5a1
3 changed files with 57 additions and 21 deletions

View file

@ -12,6 +12,10 @@ std::chrono::duration<double, std::milli> GetPerformanceTimer(TimerID timer){
return totalTimes[timer]; return totalTimes[timer];
} }
void ResetPerformanceTimer(TimerID timer) {
totalTimes[timer] = {};
}
void ResetPerformanceTimers(){ void ResetPerformanceTimers(){
totalTimes = {}; totalTimes = {};
} }

View file

@ -32,6 +32,7 @@ typedef enum {
void StartPerformanceTimer(TimerID timer); void StartPerformanceTimer(TimerID timer);
void StopPerformanceTimer(TimerID timer); void StopPerformanceTimer(TimerID timer);
std::chrono::duration<double, std::milli> GetPerformanceTimer(TimerID timer); std::chrono::duration<double, std::milli> GetPerformanceTimer(TimerID timer);
void ResetPerformanceTimer(TimerID timer);
void ResetPerformanceTimers(); void ResetPerformanceTimers();
static std::array<std::chrono::duration<double, std::milli>, PT_MAX> totalTimes = {}; static std::array<std::chrono::duration<double, std::milli>, PT_MAX> totalTimes = {};
static std::array<std::chrono::high_resolution_clock::time_point, PT_MAX> timeStarted = {}; static std::array<std::chrono::high_resolution_clock::time_point, PT_MAX> timeStarted = {};

View file

@ -167,6 +167,7 @@ bool hideCollected = false;
bool showHidden = true; bool showHidden = true;
bool mystery = false; bool mystery = false;
bool showLogicTooltip = false; bool showLogicTooltip = false;
bool enableAvailableChecks = false;
bool onlyShowAvailable = false; bool onlyShowAvailable = false;
SceneID DungeonSceneLookupByArea(RandomizerCheckArea area) { SceneID DungeonSceneLookupByArea(RandomizerCheckArea area) {
@ -896,7 +897,8 @@ void CheckTrackerWindow::DrawElement() {
showHidden = CVarGetInteger(CVAR_TRACKER_CHECK("ShowHidden"), 0); showHidden = CVarGetInteger(CVAR_TRACKER_CHECK("ShowHidden"), 0);
mystery = CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0); mystery = CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0);
showLogicTooltip = CVarGetInteger(CVAR_TRACKER_CHECK("ShowLogic"), 0); showLogicTooltip = CVarGetInteger(CVAR_TRACKER_CHECK("ShowLogic"), 0);
onlyShowAvailable = CVarGetInteger(CVAR_TRACKER_CHECK("OnlyShowAvailable"), 0); enableAvailableChecks = CVarGetInteger(CVAR_TRACKER_CHECK("EnableAvailableChecks"), 0);
onlyShowAvailable = CVarGetInteger(CVAR_TRACKER_CHECK("OnlyShowAvailable"), 0);
hideShopUnshuffledChecks = CVarGetInteger(CVAR_TRACKER_CHECK("HideUnshuffledShopChecks"), 1); hideShopUnshuffledChecks = CVarGetInteger(CVAR_TRACKER_CHECK("HideUnshuffledShopChecks"), 1);
alwaysShowGS = CVarGetInteger(CVAR_TRACKER_CHECK("AlwaysShowGSLocs"), 0); alwaysShowGS = CVarGetInteger(CVAR_TRACKER_CHECK("AlwaysShowGSLocs"), 0);
@ -950,9 +952,11 @@ void CheckTrackerWindow::DrawElement() {
UIWidgets::CVarCheckbox( UIWidgets::CVarCheckbox(
"Show Hidden Items", CVAR_TRACKER_CHECK("ShowHidden"), UIWidgets::CheckboxOptions({{ .tooltip = "When active, items will show hidden checks by default when updated to this state." }}) "Show Hidden Items", CVAR_TRACKER_CHECK("ShowHidden"), UIWidgets::CheckboxOptions({{ .tooltip = "When active, items will show hidden checks by default when updated to this state." }})
.Color(THEME_COLOR)); .Color(THEME_COLOR));
UIWidgets::CVarCheckbox( if (enableAvailableChecks) {
"Only Show Available Checks", CVAR_TRACKER_CHECK("OnlyShowAvailable"), UIWidgets::CheckboxOptions({{ .tooltip = "When active, unavailable checks will be hidden." }}) UIWidgets::CVarCheckbox(
.Color(THEME_COLOR)); "Only Show Available Checks", CVAR_TRACKER_CHECK("OnlyShowAvailable"), UIWidgets::CheckboxOptions({{ .tooltip = "When active, unavailable checks will be hidden." }})
.Color(THEME_COLOR));
}
UIWidgets::PaddedSeparator(); UIWidgets::PaddedSeparator();
if (UIWidgets::Button("Expand All", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(UIWidgets::Sizes::Inline))) { if (UIWidgets::Button("Expand All", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(UIWidgets::Sizes::Inline))) {
optCollapseAll = false; optCollapseAll = false;
@ -978,7 +982,13 @@ void CheckTrackerWindow::DrawElement() {
ImGui::Separator(); ImGui::Separator();
ImGui::Text("Total Checks: %d Available / %d Checked / %d Total", totalChecksAvailable, totalChecksGotten, totalChecks); std::ostringstream totalChecksSS;
totalChecksSS << "Total Checks: ";
if (enableAvailableChecks) {
totalChecksSS << totalChecksAvailable << " Available / ";
}
totalChecksSS << totalChecksGotten << " Checked / " << totalChecks << " Total";
ImGui::Text(totalChecksSS.str().c_str());
UIWidgets::PaddedSeparator(); UIWidgets::PaddedSeparator();
@ -1031,7 +1041,7 @@ void CheckTrackerWindow::DrawElement() {
} }
if ((shouldHideFilteredAreas && filterAreasHidden[rcArea]) || if ((shouldHideFilteredAreas && filterAreasHidden[rcArea]) ||
(!showHidden && ((hideComplete && thisAreaFullyChecked) || (hideIncomplete && !thisAreaFullyChecked))) || (!showHidden && ((hideComplete && thisAreaFullyChecked) || (hideIncomplete && !thisAreaFullyChecked))) ||
(onlyShowAvailable && areaChecksAvailable[rcArea] == 0) (enableAvailableChecks && onlyShowAvailable && areaChecksAvailable[rcArea] == 0)
) { ) {
doDraw = false; doDraw = false;
} else { } else {
@ -1070,18 +1080,27 @@ void CheckTrackerWindow::DrawElement() {
isThisAreaSpoiled = IsAreaSpoiled(rcArea) || mqSpoilers; isThisAreaSpoiled = IsAreaSpoiled(rcArea) || mqSpoilers;
if (isThisAreaSpoiled) { if (isThisAreaSpoiled) {
std::ostringstream areaTotalsSS;
std::ostringstream areaTotalsTooltipSS;
areaTotalsSS << "(";
if (enableAvailableChecks) {
areaTotalsSS << static_cast<uint16_t>(areaChecksAvailable[rcArea]) << " / ";
areaTotalsTooltipSS << "Available / ";
}
areaTotalsSS << static_cast<uint16_t>(areaChecksGotten[rcArea]) << " / " << static_cast<uint16_t>(areaCheckTotals[rcArea]) << ")";
areaTotalsTooltipSS << "Checked / Total";
if (showVOrMQ && RandomizerCheckObjects::AreaIsDungeon(rcArea)) { if (showVOrMQ && RandomizerCheckObjects::AreaIsDungeon(rcArea)) {
if (OTRGlobals::Instance->gRandoContext->GetDungeons()->GetDungeonFromScene(DungeonSceneLookupByArea(rcArea))->IsMQ()) { if (OTRGlobals::Instance->gRandoContext->GetDungeons()->GetDungeonFromScene(DungeonSceneLookupByArea(rcArea))->IsMQ()) {
ImGui::Text("(%d / %d / %d) - MQ", areaChecksAvailable[rcArea], areaChecksGotten[rcArea], areaCheckTotals[rcArea]); areaTotalsSS << " - MQ";
UIWidgets::Tooltip("Available / Checked / Total");
} else { } else {
ImGui::Text("(%d / %d / %d) - Vanilla", areaChecksAvailable[rcArea], areaChecksGotten[rcArea], areaCheckTotals[rcArea]); areaTotalsSS << " - Vanilla";
UIWidgets::Tooltip("Available / Checked / Total");
} }
} else {
ImGui::Text("(%d / %d / %d)", areaChecksAvailable[rcArea], areaChecksGotten[rcArea], areaCheckTotals[rcArea]);
UIWidgets::Tooltip("Available / Checked / Total");
} }
ImGui::Text(areaTotalsSS.str().c_str());
UIWidgets::Tooltip(areaTotalsTooltipSS.str().c_str());
} else { } else {
ImGui::Text("???"); ImGui::Text("???");
} }
@ -1095,7 +1114,7 @@ void CheckTrackerWindow::DrawElement() {
} }
for (auto rc : checks) { for (auto rc : checks) {
if (doDraw && isThisAreaSpoiled && !filterChecksHidden[rc] && if (doDraw && isThisAreaSpoiled && !filterChecksHidden[rc] &&
(!onlyShowAvailable || OTRGlobals::Instance->gRandoContext->GetItemLocation(rc)->IsAvailable())) { (!enableAvailableChecks || !onlyShowAvailable || OTRGlobals::Instance->gRandoContext->GetItemLocation(rc)->IsAvailable())) {
DrawLocation(rc); DrawLocation(rc);
} }
} }
@ -1632,14 +1651,16 @@ void DrawLocation(RandomizerCheck rc) {
//Draw //Draw
ImVec4 styleColor(mainColor.r / 255.0f, mainColor.g / 255.0f, mainColor.b / 255.0f, mainColor.a / 255.0f); ImVec4 styleColor(mainColor.r / 255.0f, mainColor.g / 255.0f, mainColor.b / 255.0f, mainColor.a / 255.0f);
if (itemLoc->HasObtained()) { if (enableAvailableChecks) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0, 0, 0, 0)); if (itemLoc->HasObtained()) {
} else { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Text, styleColor); } else {
ImGui::PushStyleColor(ImGuiCol_Text, styleColor);
}
ImGui::Text("%s", available ? ICON_FA_UNLOCK : ICON_FA_LOCK);
ImGui::PopStyleColor();
ImGui::SameLine();
} }
ImGui::Text("%s", available ? ICON_FA_UNLOCK : ICON_FA_LOCK);
ImGui::PopStyleColor();
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, styleColor); ImGui::PushStyleColor(ImGuiCol_Text, styleColor);
ImGui::Text("%s", txt.c_str()); ImGui::Text("%s", txt.c_str());
@ -1792,6 +1813,11 @@ void ImGuiDrawTwoColorPickerSection(const char* text, const char* cvarMainName,
} }
void RecalculateAvailableChecks() { void RecalculateAvailableChecks() {
if (!enableAvailableChecks) {
return;
}
ResetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS);
StartPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS); StartPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS);
std::vector<RandomizerCheck> targetLocations; std::vector<RandomizerCheck> targetLocations;
@ -1899,6 +1925,11 @@ void CheckTrackerSettingsWindow::DrawElement() {
} }
UIWidgets::CVarCheckbox("Show Logic", CVAR_TRACKER_CHECK("ShowLogic"), UIWidgets::CVarCheckbox("Show Logic", CVAR_TRACKER_CHECK("ShowLogic"),
UIWidgets::CheckboxOptions().Tooltip("If enabled, will show a check's logic when hovering over it.").Color(THEME_COLOR)); UIWidgets::CheckboxOptions().Tooltip("If enabled, will show a check's logic when hovering over it.").Color(THEME_COLOR));
if (UIWidgets::CVarCheckbox("Enable Available Checks", CVAR_TRACKER_CHECK("EnableAvailableChecks"),
UIWidgets::CheckboxOptions().Tooltip("If enabled, will show the checks that are available to be collected with your current progress.").Color(THEME_COLOR))) {
enableAvailableChecks = CVarGetInteger(CVAR_TRACKER_CHECK("EnableAvailableChecks"), 0);
RecalculateAvailableChecks();
}
// Filtering settings // Filtering settings
UIWidgets::PaddedSeparator(); UIWidgets::PaddedSeparator();