mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -07:00
Added Access -> Available on connections.
This commit is contained in:
parent
c76ead04fb
commit
656443e7a1
1 changed files with 101 additions and 45 deletions
|
@ -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<std::string> 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<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);
|
||||
|
||||
|
@ -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<std::string> 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue