Updated Check drawing.

This commit is contained in:
Anthony Stewart 2025-07-09 19:57:06 -05:00 committed by xxAtrain223
commit 574f02533d
2 changed files with 81 additions and 27 deletions

View file

@ -1928,8 +1928,8 @@ void DrawLocation(RandomizerCheck rc) {
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushID((std::to_string(rc) + "_SHOW_LOGIC").c_str()); ImGui::PushID((std::to_string(rc) + "_SHOW_CHECK_LOGIC").c_str());
if (ImGui::Button("Show Logic")) { if (ImGui::Button("Show Check Logic")) {
LogicTrackerWindow::ShowRandomizerCheck(rc); LogicTrackerWindow::ShowRandomizerCheck(rc);
} }
ImGui::PopID(); ImGui::PopID();

View file

@ -31,13 +31,18 @@ struct LogicTrackerCheck {
bool CombineAll = false; bool CombineAll = false;
bool CombineChild = false; bool CombineChild = false;
bool CombineAdult = false; bool CombineAdult = false;
bool ChildDayAccess = false;
bool ChildNightAccess = false;
bool AdultDayAccess = false;
bool AdultNightAccess = false;
}; };
std::string CheckName; std::string CheckName;
std::vector<Region> Regions; std::vector<Region> Regions;
}; };
static std::vector<LogicTrackerCheck> checks; std::unique_ptr<LogicTrackerCheck> check;
LogicTrackerCheck::Region::ExpressionRow CreateExpressionRows(const std::shared_ptr<LogicExpression>& expression) { LogicTrackerCheck::Region::ExpressionRow CreateExpressionRows(const std::shared_ptr<LogicExpression>& expression) {
LogicTrackerCheck::Region::ExpressionRow row; LogicTrackerCheck::Region::ExpressionRow row;
@ -95,22 +100,26 @@ static std::tuple<bool, bool, bool> CalculateCombines(const LogicTrackerCheck::R
return {combineAll, combineChild, combineAdult}; return {combineAll, combineChild, combineAdult};
} }
void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) { bool expandCheck = false;
checks.clear();
const auto& location = Rando::StaticData::GetLocation(check); void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
const auto& location = Rando::StaticData::GetLocation(randomizerCheck);
LogicTrackerCheck logicTrackerCheck; check = std::make_unique<LogicTrackerCheck>();
logicTrackerCheck.CheckName = location->GetName(); check->CheckName = location->GetName();
for (const auto& region : areaTable) { for (const auto& region : areaTable) {
for (const auto& locationAccess : region.locations) { for (const auto& locationAccess : region.locations) {
if (locationAccess.GetLocation() == check) { if (locationAccess.GetLocation() == randomizerCheck) {
LogicTrackerCheck::Region regionAgeTime; LogicTrackerCheck::Region regionAgeTime;
regionAgeTime.RegionName = region.regionName; regionAgeTime.RegionName = region.regionName;
regionAgeTime.Root = CreateExpressionRows(LogicExpression::Parse(locationAccess.GetConditionStr())); 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->IsChild = true;
logic->AtDay = true; logic->AtDay = true;
@ -120,7 +129,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) {
logic->IsChild = false; logic->IsChild = false;
logic->AtDay = false; logic->AtDay = false;
} }
if (region.childNight) { if (regionAgeTime.ChildNightAccess) {
logic->IsChild = true; logic->IsChild = true;
logic->AtNight = true; logic->AtNight = true;
@ -130,7 +139,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) {
logic->IsChild = false; logic->IsChild = false;
logic->AtNight = false; logic->AtNight = false;
} }
if (region.adultDay) { if (regionAgeTime.AdultDayAccess) {
logic->IsAdult = true; logic->IsAdult = true;
logic->AtDay = true; logic->AtDay = true;
@ -140,7 +149,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) {
logic->IsAdult = false; logic->IsAdult = false;
logic->AtDay = false; logic->AtDay = false;
} }
if (region.adultNight) { if (regionAgeTime.AdultNightAccess) {
logic->IsAdult = true; logic->IsAdult = true;
logic->AtNight = true; logic->AtNight = true;
@ -156,16 +165,15 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck check) {
regionAgeTime.CombineChild = combineChild; regionAgeTime.CombineChild = combineChild;
regionAgeTime.CombineAdult = combineAdult; 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"); auto window = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Logic Tracker");
window->Show(); window->Show();
ImGui::SetWindowFocus(window->GetName().c_str()); ImGui::SetWindowFocus(window->GetName().c_str());
expandCheck = true;
} }
static std::string ToString(const std::optional<LogicExpression::ValueVariant>& value) { static std::string ToString(const std::optional<LogicExpression::ValueVariant>& value) {
@ -310,7 +318,7 @@ static void DrawExpressionRow(const LogicTrackerCheck::Region& region, LogicTrac
ImGui::PopFont(); ImGui::PopFont();
} }
static void DrawCheckRegion(LogicTrackerCheck::Region& region) { static void DrawCheckRegionTable(LogicTrackerCheck::Region& region) {
int columnCount = 3; int columnCount = 3;
if (!region.CombineAll) { if (!region.CombineAll) {
if (!region.CombineChild) { if (!region.CombineChild) {
@ -350,21 +358,67 @@ static void DrawCheckRegion(LogicTrackerCheck::Region& region) {
ImGui::EndTable(); ImGui::EndTable();
} }
static void DrawCheck(LogicTrackerCheck& check) { static void DrawCheckRegion(LogicTrackerCheck::Region& region) {
ImGui::SeparatorText(("Check: " + check.CheckName).c_str()); ImGui::SeparatorText(("Region: " + region.RegionName).c_str());
if (check.Regions.empty()) {
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();
}
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."); ImGui::Text("No regions found for this check.");
return; return;
} }
for (auto& region : check.Regions) { for (auto& region : check->Regions) {
DrawCheckRegion(region); DrawCheckRegion(region);
ImGui::Dummy(ImVec2(0.0f, 20.0f));
}
} }
} }
void LogicTrackerWindow::DrawElement() { void LogicTrackerWindow::DrawElement() {
for (auto& check : checks) { DrawCheck();
DrawCheck(check);
}
} }
void LogicTrackerWindow::InitElement() { void LogicTrackerWindow::InitElement() {