From 656443e7a11d0820e899d3ab06c3b1625a8d8ad1 Mon Sep 17 00:00:00 2001 From: xxAtrain223 Date: Mon, 14 Jul 2025 20:51:57 -0500 Subject: [PATCH] Added Access -> Available on connections. --- .../randomizer/randomizer_logic_tracker.cpp | 146 ++++++++++++------ 1 file changed, 101 insertions(+), 45 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp index 3c7a41df2..b831691bb 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_logic_tracker.cpp @@ -412,6 +412,102 @@ static void DrawNodeConnection(LogicTrackerNode& node, LogicTrackerNode::Connect DrawExpressionTable(connection.ExpressionTable); } +static std::string GetAccessString(const LogicTrackerNode::Connection& connection) { + std::string access = ""; + if (connection.ChildDayAccess && connection.ChildNightAccess && connection.AdultDayAccess && + connection.AdultNightAccess) { + access += "All"; + } else if (connection.ChildDayAccess || connection.ChildNightAccess || connection.AdultDayAccess || + connection.AdultNightAccess) { + std::vector accessParts; + if (connection.ChildDayAccess && connection.ChildNightAccess) { + accessParts.push_back("Child"); + } else { + if (connection.ChildDayAccess) { + accessParts.push_back("Child Day"); + } + if (connection.ChildNightAccess) { + accessParts.push_back("Child Night"); + } + } + if (connection.AdultDayAccess && connection.AdultNightAccess) { + accessParts.push_back("Adult"); + } else { + if (connection.AdultDayAccess) { + accessParts.push_back("Adult Day"); + } + if (connection.AdultNightAccess) { + accessParts.push_back("Adult Night"); + } + } + if (!accessParts.empty()) { + for (size_t i = 0; i < accessParts.size(); ++i) { + if (i > 0) { + access += ", "; + } + access += accessParts[i]; + } + } + } else { + access = "None"; + } + return access; +} + +static bool ToBool(const std::optional& value) { + if (!value.has_value()) { + return false; + } + return LogicExpression::GetValue(value.value()); +} + +static std::string GetAvailableString(const LogicTrackerNode::Connection& connection) { + const auto& expressionRow = connection.ExpressionTable.Root; + + bool childDay = ToBool(expressionRow.ChildDay); + bool childNight = ToBool(expressionRow.ChildNight); + bool adultDay = ToBool(expressionRow.AdultDay); + bool adultNight = ToBool(expressionRow.AdultNight); + + std::string available = ""; + if (childDay && childNight && adultDay && adultNight) { + available += "All"; + } else if (childDay || childNight || adultDay || adultNight) { + std::vector availableParts; + if (childDay && childNight) { + availableParts.push_back("Child"); + } else { + if (childDay) { + availableParts.push_back("Child Day"); + } + if (childNight) { + availableParts.push_back("Child Night"); + } + } + if (adultDay && adultNight) { + availableParts.push_back("Adult"); + } else { + if (adultDay) { + availableParts.push_back("Adult Day"); + } + if (adultNight) { + availableParts.push_back("Adult Night"); + } + } + if (!availableParts.empty()) { + for (size_t i = 0; i < availableParts.size(); ++i) { + if (i > 0) { + available += ", "; + } + available += availableParts[i]; + } + } + } else { + available = "None"; + } + return available; +} + static void DrawNode(LogicTrackerNode& node) { ImGui::PushID(node.NodeId); @@ -434,48 +530,8 @@ static void DrawNode(LogicTrackerNode& node) { auto& connectionHeader = connection.ParentName; - std::string access = ""; - if (connection.ChildDayAccess && connection.ChildNightAccess && connection.AdultDayAccess && - connection.AdultNightAccess) { - access += "All"; - } else if (connection.ChildDayAccess || connection.ChildNightAccess || connection.AdultDayAccess || - connection.AdultNightAccess) { - std::vector accessParts; - if (connection.ChildDayAccess && connection.ChildNightAccess) { - accessParts.push_back("Child"); - } else { - if (connection.ChildDayAccess) { - accessParts.push_back("Child Day"); - } - if (connection.ChildNightAccess) { - accessParts.push_back("Child Night"); - } - } - if (connection.AdultDayAccess && connection.AdultNightAccess) { - accessParts.push_back("Adult"); - } else { - if (connection.AdultDayAccess) { - accessParts.push_back("Adult Day"); - } - if (connection.AdultNightAccess) { - accessParts.push_back("Adult Night"); - } - } - if (!accessParts.empty()) { - for (size_t i = 0; i < accessParts.size(); ++i) { - if (i > 0) { - access += ", "; - } - access += accessParts[i]; - } - } - } else { - access = "None"; - } - - if (expandingNode) { - ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always); - } + std::string accessAvailable = + GetAccessString(connection) + " " + ICON_FA_ARROW_RIGHT + " " + GetAvailableString(connection); bool connectionOpen = ImGui::CollapsingHeader(("From " + connection.ParentName).c_str(), @@ -484,10 +540,10 @@ static void DrawNode(LogicTrackerNode& node) { ImGui::SetTooltip("Show Connection Logic"); } - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(access.c_str()).x); - ImGui::TextUnformatted(access.c_str()); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(accessAvailable.c_str()).x); + ImGui::TextUnformatted(accessAvailable.c_str()); if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Connection Access"); + ImGui::SetTooltip("Connection Access " ICON_FA_ARROW_RIGHT " Available"); } ImGui::SameLine();