mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 13:53:49 -07:00
Logic Tracker drawing updates.
This commit is contained in:
parent
759fc019ad
commit
feac6d1186
2 changed files with 86 additions and 60 deletions
|
@ -47,6 +47,7 @@ struct LogicTrackerNode {
|
||||||
std::string NodeName;
|
std::string NodeName;
|
||||||
std::vector<Connection> Connections;
|
std::vector<Connection> Connections;
|
||||||
int NodeId = -1;
|
int NodeId = -1;
|
||||||
|
RandomizerRegion RandomizerRegion = RR_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool expandingNode = false;
|
bool expandingNode = false;
|
||||||
|
@ -165,7 +166,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
|
|
||||||
LogicTrackerNode node;
|
LogicTrackerNode node;
|
||||||
node.NodeName = location->GetName();
|
node.NodeName = "Check: " + location->GetName();
|
||||||
node.NodeId = nodes.size();
|
node.NodeId = nodes.size();
|
||||||
|
|
||||||
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
||||||
|
@ -173,7 +174,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
for (const auto& locationAccess : region.locations) {
|
for (const auto& locationAccess : region.locations) {
|
||||||
if (locationAccess.GetLocation() == randomizerCheck) {
|
if (locationAccess.GetLocation() == randomizerCheck) {
|
||||||
LogicTrackerNode::Connection connection;
|
LogicTrackerNode::Connection connection;
|
||||||
connection.ParentName = region.regionName;
|
connection.ParentName = "Region: " + region.regionName;
|
||||||
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
||||||
connection.ChildDayAccess = region.childDay;
|
connection.ChildDayAccess = region.childDay;
|
||||||
connection.ChildNightAccess = region.childNight;
|
connection.ChildNightAccess = region.childNight;
|
||||||
|
@ -195,18 +196,23 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
expandNodeId = node.NodeId;
|
expandNodeId = node.NodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion randomizerRegion) {
|
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegion, RandomizerRegion fromRandomizerRegion) {
|
||||||
const auto& region = RegionTable(randomizerRegion);
|
const auto& region = RegionTable(toRandomizerRegion);
|
||||||
|
|
||||||
LogicTrackerNode node;
|
LogicTrackerNode node;
|
||||||
node.NodeName = region->regionName;
|
node.NodeName = "Region: " + region->regionName;
|
||||||
node.NodeId = nodes.size();
|
node.NodeId = nodes.size();
|
||||||
|
node.RandomizerRegion = toRandomizerRegion;
|
||||||
|
|
||||||
for (const auto& entrance : region->entrances) {
|
for (const auto& entrance : region->entrances) {
|
||||||
|
if (entrance->GetParentRegionKey() == fromRandomizerRegion) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto& parentRegion = entrance->GetParentRegion();
|
const auto& parentRegion = entrance->GetParentRegion();
|
||||||
|
|
||||||
LogicTrackerNode::Connection connection;
|
LogicTrackerNode::Connection connection;
|
||||||
connection.ParentName = parentRegion->regionName;
|
connection.ParentName = "Region: " + parentRegion->regionName;
|
||||||
connection.ParentRandomizerRegion = entrance->GetParentRegionKey();
|
connection.ParentRandomizerRegion = entrance->GetParentRegionKey();
|
||||||
connection.ChildDayAccess = parentRegion->childDay;
|
connection.ChildDayAccess = parentRegion->childDay;
|
||||||
connection.ChildNightAccess = parentRegion->childNight;
|
connection.ChildNightAccess = parentRegion->childNight;
|
||||||
|
@ -408,53 +414,7 @@ static void DrawExpressionTable(ExpressionTable& table) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawNodeConnection(LogicTrackerNode& node, LogicTrackerNode::Connection& connection) {
|
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);
|
DrawExpressionTable(connection.ExpressionTable);
|
||||||
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawNode(LogicTrackerNode& node) {
|
static void DrawNode(LogicTrackerNode& node) {
|
||||||
|
@ -464,16 +424,82 @@ static void DrawNode(LogicTrackerNode& node) {
|
||||||
ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always);
|
ImGui::SetNextItemOpen(expandNodeId == node.NodeId, ImGuiCond_Always);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader(node.NodeName.c_str(),
|
bool nodeOpen = ImGui::CollapsingHeader(("To " + node.NodeName).c_str(),
|
||||||
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth)) {
|
ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||||
ImGui::Indent(25.0f);
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::SetTooltip("Show Connections");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeOpen) {
|
||||||
for (int i = 0; i < node.Connections.size(); i++) {
|
for (int i = 0; i < node.Connections.size(); i++) {
|
||||||
if (ImGui::CollapsingHeader(node.Connections[i].ParentName.c_str(), ImGuiTreeNodeFlags_AllowOverlap |
|
auto& connection = node.Connections[i];
|
||||||
ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
ImGui::PushID(connection.ParentName.c_str());
|
||||||
DrawNodeConnection(node, node.Connections[i]);
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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::Unindent(25.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
|
@ -8,7 +8,7 @@ class LogicTrackerWindow : public Ship::GuiWindow {
|
||||||
void DrawElement() override;
|
void DrawElement() override;
|
||||||
|
|
||||||
static void ShowRandomizerCheck(RandomizerCheck randomizerCheck);
|
static void ShowRandomizerCheck(RandomizerCheck randomizerCheck);
|
||||||
static void ShowRandomizerRegion(RandomizerRegion randomizerRegion);
|
static void ShowRandomizerRegion(RandomizerRegion toRandomizerRegion, RandomizerRegion fromRandomizerRegion);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InitElement() override;
|
void InitElement() override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue