Logic Tracker drawing updates.

This commit is contained in:
Anthony Stewart 2025-07-11 22:51:52 -05:00 committed by xxAtrain223
commit feac6d1186
2 changed files with 86 additions and 60 deletions

View file

@ -47,6 +47,7 @@ struct LogicTrackerNode {
std::string NodeName;
std::vector<Connection> Connections;
int NodeId = -1;
RandomizerRegion RandomizerRegion = RR_NONE;
};
bool expandingNode = false;
@ -165,7 +166,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
nodes.clear();
LogicTrackerNode node;
node.NodeName = location->GetName();
node.NodeName = "Check: " + location->GetName();
node.NodeId = nodes.size();
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
@ -173,7 +174,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
for (const auto& locationAccess : region.locations) {
if (locationAccess.GetLocation() == randomizerCheck) {
LogicTrackerNode::Connection connection;
connection.ParentName = region.regionName;
connection.ParentName = "Region: " + region.regionName;
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
connection.ChildDayAccess = region.childDay;
connection.ChildNightAccess = region.childNight;
@ -195,18 +196,23 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
expandNodeId = node.NodeId;
}
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion randomizerRegion) {
const auto& region = RegionTable(randomizerRegion);
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegion, RandomizerRegion fromRandomizerRegion) {
const auto& region = RegionTable(toRandomizerRegion);
LogicTrackerNode node;
node.NodeName = region->regionName;
node.NodeName = "Region: " + region->regionName;
node.NodeId = nodes.size();
node.RandomizerRegion = toRandomizerRegion;
for (const auto& entrance : region->entrances) {
if (entrance->GetParentRegionKey() == fromRandomizerRegion) {
continue;
}
const auto& parentRegion = entrance->GetParentRegion();
LogicTrackerNode::Connection connection;
connection.ParentName = parentRegion->regionName;
connection.ParentName = "Region: " + parentRegion->regionName;
connection.ParentRandomizerRegion = entrance->GetParentRegionKey();
connection.ChildDayAccess = parentRegion->childDay;
connection.ChildNightAccess = parentRegion->childNight;
@ -408,53 +414,7 @@ static void DrawExpressionTable(ExpressionTable& table) {
}
static void DrawNodeConnection(LogicTrackerNode& node, LogicTrackerNode::Connection& connection) {
ImGui::PushID(connection.ParentName.c_str());
ImGui::TextUnformatted("Parent Access:");
if (ImGui::BeginTable("", 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(connection.ChildDayAccess ? "true" : "false");
ImGui::TableNextColumn();
ImGui::TextUnformatted(connection.ChildNightAccess ? "true" : "false");
ImGui::TableNextColumn();
ImGui::TextUnformatted(connection.AdultDayAccess ? "true" : "false");
ImGui::TableNextColumn();
ImGui::TextUnformatted(connection.AdultNightAccess ? "true" : "false");
ImGui::PopFont();
ImGui::EndTable();
}
if (connection.ParentRandomizerRegion != RR_NONE) {
ImGui::SameLine();
if (ImGui::Button("Show Region Logic")) {
while (nodes.back().NodeId > node.NodeId) {
nodes.pop_back();
}
LogicTrackerWindow::ShowRandomizerRegion(connection.ParentRandomizerRegion);
}
}
ImGui::TextUnformatted("Node Access:");
DrawExpressionTable(connection.ExpressionTable);
ImGui::PopID();
}
static void DrawNode(LogicTrackerNode& node) {
@ -464,16 +424,82 @@ static void DrawNode(LogicTrackerNode& node) {
ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always);
}
if (ImGui::CollapsingHeader(node.NodeName.c_str(),
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth)) {
ImGui::Indent(25.0f);
bool nodeOpen = ImGui::CollapsingHeader(("To " + node.NodeName).c_str(),
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show Connections");
}
if (nodeOpen) {
for (int i = 0; i < node.Connections.size(); i++) {
if (ImGui::CollapsingHeader(node.Connections[i].ParentName.c_str(), ImGuiTreeNodeFlags_AllowOverlap |
ImGuiTreeNodeFlags_SpanAvailWidth)) {
DrawNodeConnection(node, node.Connections[i]);
auto& connection = node.Connections[i];
ImGui::PushID(connection.ParentName.c_str());
auto& connectionHeader = connection.ParentName;
std::string access = "";
if (connection.ChildDayAccess && connection.ChildNightAccess && connection.AdultDayAccess &&
connection.AdultNightAccess) {
access += "All";
} else {
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");
}
}
ImGui::Unindent(25.0f);
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];
}
}
}
if (ImGui::Button(ICON_FA_COGS)) {
LogicTrackerWindow::ShowRandomizerRegion(connection.ParentRandomizerRegion, node.RandomizerRegion);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show Region Logic");
}
ImGui::SameLine();
bool connectionOpen = ImGui::CollapsingHeader(
("From " + connection.ParentName).c_str(), ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanAvailWidth);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show Connection Logic");
}
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(access.c_str()).x);
ImGui::TextUnformatted(access.c_str());
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Connection Access");
}
if (connectionOpen) {
DrawNodeConnection(node, connection);
}
ImGui::PopID();
}
}
ImGui::PopID();

View file

@ -8,7 +8,7 @@ class LogicTrackerWindow : public Ship::GuiWindow {
void DrawElement() override;
static void ShowRandomizerCheck(RandomizerCheck randomizerCheck);
static void ShowRandomizerRegion(RandomizerRegion randomizerRegion);
static void ShowRandomizerRegion(RandomizerRegion toRandomizerRegion, RandomizerRegion fromRandomizerRegion);
protected:
void InitElement() override;