Added Access -> Available on connections.

This commit is contained in:
xxAtrain223 2025-07-14 20:51:57 -05:00
commit 656443e7a1

View file

@ -412,28 +412,7 @@ static void DrawNodeConnection(LogicTrackerNode& node, LogicTrackerNode::Connect
DrawExpressionTable(connection.ExpressionTable); DrawExpressionTable(connection.ExpressionTable);
} }
static void DrawNode(LogicTrackerNode& node) { static std::string GetAccessString(const LogicTrackerNode::Connection& connection) {
ImGui::PushID(node.NodeId);
if (expandingNode) {
ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always);
}
bool nodeOpen = ImGui::CollapsingHeader(("To " + node.NodeName).c_str(),
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show Connections");
}
if (nodeOpen) {
ImGui::Indent(25.0f);
for (int i = 0; i < node.Connections.size(); i++) {
auto& connection = node.Connections[i];
ImGui::PushID(connection.ParentName.c_str());
auto& connectionHeader = connection.ParentName;
std::string access = ""; std::string access = "";
if (connection.ChildDayAccess && connection.ChildNightAccess && connection.AdultDayAccess && if (connection.ChildDayAccess && connection.ChildNightAccess && connection.AdultDayAccess &&
connection.AdultNightAccess) { connection.AdultNightAccess) {
@ -472,11 +451,88 @@ static void DrawNode(LogicTrackerNode& node) {
} else { } else {
access = "None"; access = "None";
} }
return access;
}
static bool ToBool(const std::optional<LogicExpression::ValueVariant>& value) {
if (!value.has_value()) {
return false;
}
return LogicExpression::GetValue<bool>(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<std::string> 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);
if (expandingNode) { if (expandingNode) {
ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always); ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always);
} }
bool nodeOpen = ImGui::CollapsingHeader(("To " + node.NodeName).c_str(),
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show Connections");
}
if (nodeOpen) {
ImGui::Indent(25.0f);
for (int i = 0; i < node.Connections.size(); i++) {
auto& connection = node.Connections[i];
ImGui::PushID(connection.ParentName.c_str());
auto& connectionHeader = connection.ParentName;
std::string accessAvailable =
GetAccessString(connection) + " " + ICON_FA_ARROW_RIGHT + " " + GetAvailableString(connection);
bool connectionOpen = bool connectionOpen =
ImGui::CollapsingHeader(("From " + connection.ParentName).c_str(), ImGui::CollapsingHeader(("From " + connection.ParentName).c_str(),
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanAvailWidth); ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanAvailWidth);
@ -484,10 +540,10 @@ static void DrawNode(LogicTrackerNode& node) {
ImGui::SetTooltip("Show Connection Logic"); ImGui::SetTooltip("Show Connection Logic");
} }
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(access.c_str()).x); ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(accessAvailable.c_str()).x);
ImGui::TextUnformatted(access.c_str()); ImGui::TextUnformatted(accessAvailable.c_str());
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Connection Access"); ImGui::SetTooltip("Connection Access " ICON_FA_ARROW_RIGHT " Available");
} }
ImGui::SameLine(); ImGui::SameLine();