diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 5bcbd6b3e..81ca6fa14 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1928,8 +1928,8 @@ void DrawLocation(RandomizerCheck rc) { } ImGui::SameLine(); - ImGui::PushID((std::to_string(rc) + "_SHOW_LOGIC").c_str()); - if (ImGui::Button("Show Logic")) { + ImGui::PushID((std::to_string(rc) + "_SHOW_CHECK_LOGIC").c_str()); + if (ImGui::Button("Show Check Logic")) { LogicTrackerWindow::ShowRandomizerCheck(rc); } ImGui::PopID(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp index 5dcc22237..561feb3c5 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp @@ -31,13 +31,18 @@ struct LogicTrackerCheck { bool CombineAll = false; bool CombineChild = false; bool CombineAdult = false; + + bool ChildDayAccess = false; + bool ChildNightAccess = false; + bool AdultDayAccess = false; + bool AdultNightAccess = false; }; std::string CheckName; std::vector Regions; }; -static std::vector checks; +std::unique_ptr check; LogicTrackerCheck::Region::ExpressionRow CreateExpressionRows(const std::shared_ptr& expression) { LogicTrackerCheck::Region::ExpressionRow row; @@ -95,22 +100,26 @@ static std::tuple CalculateCombines(const LogicTrackerCheck::R return {combineAll, combineChild, combineAdult}; } -void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) { - checks.clear(); +bool expandCheck = false; - const auto& location = Rando::StaticData::GetLocation(check); +void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) { + const auto& location = Rando::StaticData::GetLocation(randomizerCheck); - LogicTrackerCheck logicTrackerCheck; - logicTrackerCheck.CheckName = location->GetName(); + check = std::make_unique(); + check->CheckName = location->GetName(); for (const auto& region : areaTable) { for (const auto& locationAccess : region.locations) { - if (locationAccess.GetLocation() == check) { + if (locationAccess.GetLocation() == randomizerCheck) { LogicTrackerCheck::Region regionAgeTime; regionAgeTime.RegionName = region.regionName; regionAgeTime.Root = CreateExpressionRows(LogicExpression::Parse(locationAccess.GetConditionStr())); + regionAgeTime.ChildDayAccess = region.childDay; + regionAgeTime.ChildNightAccess = region.childNight; + regionAgeTime.AdultDayAccess = region.adultDay; + regionAgeTime.AdultNightAccess = region.adultNight; - if (region.childDay) { + if (regionAgeTime.ChildDayAccess) { logic->IsChild = true; logic->AtDay = true; @@ -120,7 +129,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) { logic->IsChild = false; logic->AtDay = false; } - if (region.childNight) { + if (regionAgeTime.ChildNightAccess) { logic->IsChild = true; logic->AtNight = true; @@ -130,7 +139,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) { logic->IsChild = false; logic->AtNight = false; } - if (region.adultDay) { + if (regionAgeTime.AdultDayAccess) { logic->IsAdult = true; logic->AtDay = true; @@ -140,7 +149,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) { logic->IsAdult = false; logic->AtDay = false; } - if (region.adultNight) { + if (regionAgeTime.AdultNightAccess) { logic->IsAdult = true; logic->AtNight = true; @@ -156,16 +165,15 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) { regionAgeTime.CombineChild = combineChild; regionAgeTime.CombineAdult = combineAdult; - logicTrackerCheck.Regions.emplace_back(std::move(regionAgeTime)); + check->Regions.emplace_back(std::move(regionAgeTime)); } } } - checks.emplace_back(std::move(logicTrackerCheck)); - auto window = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Logic Tracker"); window->Show(); ImGui::SetWindowFocus(window->GetName().c_str()); + expandCheck = true; } static std::string ToString(const std::optional& value) { @@ -310,7 +318,7 @@ static void DrawExpressionRow(const LogicTrackerCheck::Region& region, LogicTrac ImGui::PopFont(); } -static void DrawCheckRegion(LogicTrackerCheck::Region& region) { +static void DrawCheckRegionTable(LogicTrackerCheck::Region& region) { int columnCount = 3; if (!region.CombineAll) { if (!region.CombineChild) { @@ -350,21 +358,67 @@ static void DrawCheckRegion(LogicTrackerCheck::Region& region) { ImGui::EndTable(); } -static void DrawCheck(LogicTrackerCheck& check) { - ImGui::SeparatorText(("Check: " + check.CheckName).c_str()); - if (check.Regions.empty()) { - ImGui::Text("No regions found for this check."); - return; +static void DrawCheckRegion(LogicTrackerCheck::Region& region) { + ImGui::SeparatorText(("Region: " + region.RegionName).c_str()); + + ImGui::TextUnformatted("Region Access:"); + + if (ImGui::BeginTable(("Region Access: " + region.RegionName).c_str(), 4, + ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoHostExtendX)) { + ImGui::TableSetupColumn("Child Day", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Child Night", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Adult Day", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Adult Night", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableHeadersRow(); + + ImGui::TableNextRow(); + + ImGui::PushFont(OTRGlobals::Instance->fontMono); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(region.ChildDayAccess ? "true" : "false"); + + ImGui::TableNextColumn(); + ImGui::TextUnformatted(region.ChildNightAccess ? "true" : "false"); + + ImGui::TableNextColumn(); + ImGui::TextUnformatted(region.AdultDayAccess ? "true" : "false"); + + ImGui::TableNextColumn(); + ImGui::TextUnformatted(region.AdultNightAccess ? "true" : "false"); + ImGui::PopFont(); + + ImGui::EndTable(); } - for (auto& region : check.Regions) { - DrawCheckRegion(region); + + ImGui::SameLine(); + if (ImGui::Button(("Show Entrance Logic##" + region.RegionName).c_str())) { + } + + ImGui::Dummy(ImVec2(0.0f, 10.0f)); + + ImGui::TextUnformatted("Check Access:"); + DrawCheckRegionTable(region); +} + +static void DrawCheck() { + if (expandCheck) { + expandCheck = false; + ImGui::SetNextItemOpen(true, ImGuiCond_Always); + } + if (ImGui::CollapsingHeader(("Check: " + (check != nullptr ? check->CheckName : "")).c_str(), ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth)) { + if (check->Regions.empty()) { + ImGui::Text("No regions found for this check."); + return; + } + for (auto& region : check->Regions) { + DrawCheckRegion(region); + ImGui::Dummy(ImVec2(0.0f, 20.0f)); + } } } void LogicTrackerWindow::DrawElement() { - for (auto& check : checks) { - DrawCheck(check); - } + DrawCheck(); } void LogicTrackerWindow::InitElement() {