mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 06:13:45 -07:00
Updated LogicTracker IDs.
This commit is contained in:
parent
23f8520205
commit
759fc019ad
1 changed files with 65 additions and 98 deletions
|
@ -23,7 +23,7 @@ struct ExpressionTable {
|
||||||
std::optional<LogicExpression::ValueVariant> ChildNight;
|
std::optional<LogicExpression::ValueVariant> ChildNight;
|
||||||
std::optional<LogicExpression::ValueVariant> AdultDay;
|
std::optional<LogicExpression::ValueVariant> AdultDay;
|
||||||
std::optional<LogicExpression::ValueVariant> AdultNight;
|
std::optional<LogicExpression::ValueVariant> AdultNight;
|
||||||
bool Expanded;
|
bool Expanded = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ExpressionRow Root;
|
ExpressionRow Root;
|
||||||
|
@ -35,7 +35,7 @@ struct ExpressionTable {
|
||||||
struct LogicTrackerNode {
|
struct LogicTrackerNode {
|
||||||
struct Connection {
|
struct Connection {
|
||||||
std::string ParentName;
|
std::string ParentName;
|
||||||
RandomizerRegion ParentRandomizerRegion;
|
RandomizerRegion ParentRandomizerRegion = RR_NONE;
|
||||||
ExpressionTable ExpressionTable;
|
ExpressionTable ExpressionTable;
|
||||||
|
|
||||||
bool ChildDayAccess = false;
|
bool ChildDayAccess = false;
|
||||||
|
@ -46,7 +46,7 @@ struct LogicTrackerNode {
|
||||||
|
|
||||||
std::string NodeName;
|
std::string NodeName;
|
||||||
std::vector<Connection> Connections;
|
std::vector<Connection> Connections;
|
||||||
int NodeId;
|
int NodeId = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool expandingNode = false;
|
bool expandingNode = false;
|
||||||
|
@ -109,27 +109,8 @@ static std::tuple<bool, bool, bool> CalculateCombines(const ExpressionTable::Exp
|
||||||
return {combineAll, combineChild, combineAdult};
|
return {combineAll, combineChild, combineAdult};
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
static void PopulateConnectionExpression(LogicTrackerNode::Connection& connection, std::string expressionStr) {
|
||||||
const auto& location = Rando::StaticData::GetLocation(randomizerCheck);
|
connection.ExpressionTable.Root = CreateExpressionRows(LogicExpression::Parse(expressionStr));
|
||||||
|
|
||||||
nodes.clear();
|
|
||||||
|
|
||||||
LogicTrackerNode node;
|
|
||||||
node.NodeName = location->GetName();
|
|
||||||
node.NodeId = nodes.size();
|
|
||||||
|
|
||||||
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
|
||||||
const auto& region = areaTable[randomizerRegion];
|
|
||||||
for (const auto& locationAccess : region.locations) {
|
|
||||||
if (locationAccess.GetLocation() == randomizerCheck) {
|
|
||||||
LogicTrackerNode::Connection connection;
|
|
||||||
connection.ParentName = region.regionName;
|
|
||||||
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
|
||||||
connection.ExpressionTable.Root = CreateExpressionRows(LogicExpression::Parse(locationAccess.GetConditionStr()));
|
|
||||||
connection.ChildDayAccess = region.childDay;
|
|
||||||
connection.ChildNightAccess = region.childNight;
|
|
||||||
connection.AdultDayAccess = region.adultDay;
|
|
||||||
connection.AdultNightAccess = region.adultNight;
|
|
||||||
|
|
||||||
if (connection.ChildDayAccess) {
|
if (connection.ChildDayAccess) {
|
||||||
logic->IsChild = true;
|
logic->IsChild = true;
|
||||||
|
@ -176,6 +157,30 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
connection.ExpressionTable.CombineAll = combineAll;
|
connection.ExpressionTable.CombineAll = combineAll;
|
||||||
connection.ExpressionTable.CombineChild = combineChild;
|
connection.ExpressionTable.CombineChild = combineChild;
|
||||||
connection.ExpressionTable.CombineAdult = combineAdult;
|
connection.ExpressionTable.CombineAdult = combineAdult;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
|
const auto& location = Rando::StaticData::GetLocation(randomizerCheck);
|
||||||
|
|
||||||
|
nodes.clear();
|
||||||
|
|
||||||
|
LogicTrackerNode node;
|
||||||
|
node.NodeName = location->GetName();
|
||||||
|
node.NodeId = nodes.size();
|
||||||
|
|
||||||
|
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
||||||
|
const auto& region = areaTable[randomizerRegion];
|
||||||
|
for (const auto& locationAccess : region.locations) {
|
||||||
|
if (locationAccess.GetLocation() == randomizerCheck) {
|
||||||
|
LogicTrackerNode::Connection connection;
|
||||||
|
connection.ParentName = region.regionName;
|
||||||
|
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
||||||
|
connection.ChildDayAccess = region.childDay;
|
||||||
|
connection.ChildNightAccess = region.childNight;
|
||||||
|
connection.AdultDayAccess = region.adultDay;
|
||||||
|
connection.AdultNightAccess = region.adultNight;
|
||||||
|
|
||||||
|
PopulateConnectionExpression(connection, locationAccess.GetConditionStr());
|
||||||
|
|
||||||
node.Connections.emplace_back(std::move(connection));
|
node.Connections.emplace_back(std::move(connection));
|
||||||
}
|
}
|
||||||
|
@ -203,58 +208,12 @@ void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion randomizerRegion)
|
||||||
LogicTrackerNode::Connection connection;
|
LogicTrackerNode::Connection connection;
|
||||||
connection.ParentName = parentRegion->regionName;
|
connection.ParentName = parentRegion->regionName;
|
||||||
connection.ParentRandomizerRegion = entrance->GetParentRegionKey();
|
connection.ParentRandomizerRegion = entrance->GetParentRegionKey();
|
||||||
connection.ExpressionTable.Root =
|
|
||||||
CreateExpressionRows(LogicExpression::Parse(entrance->GetConditionStr()));
|
|
||||||
connection.ChildDayAccess = parentRegion->childDay;
|
connection.ChildDayAccess = parentRegion->childDay;
|
||||||
connection.ChildNightAccess = parentRegion->childNight;
|
connection.ChildNightAccess = parentRegion->childNight;
|
||||||
connection.AdultDayAccess = parentRegion->adultDay;
|
connection.AdultDayAccess = parentRegion->adultDay;
|
||||||
connection.AdultNightAccess = parentRegion->adultNight;
|
connection.AdultNightAccess = parentRegion->adultNight;
|
||||||
|
|
||||||
if (connection.ChildDayAccess) {
|
PopulateConnectionExpression(connection, entrance->GetConditionStr());
|
||||||
logic->IsChild = true;
|
|
||||||
logic->AtDay = true;
|
|
||||||
|
|
||||||
const auto& eval = EvaluateExpression(connection.ExpressionTable.Root.Expression);
|
|
||||||
PopulateExpressionValues(connection.ExpressionTable.Root, eval, AgeTime::ChildDay);
|
|
||||||
|
|
||||||
logic->IsChild = false;
|
|
||||||
logic->AtDay = false;
|
|
||||||
}
|
|
||||||
if (connection.ChildNightAccess) {
|
|
||||||
logic->IsChild = true;
|
|
||||||
logic->AtNight = true;
|
|
||||||
|
|
||||||
const auto& eval = EvaluateExpression(connection.ExpressionTable.Root.Expression);
|
|
||||||
PopulateExpressionValues(connection.ExpressionTable.Root, eval, AgeTime::ChildNight);
|
|
||||||
|
|
||||||
logic->IsChild = false;
|
|
||||||
logic->AtNight = false;
|
|
||||||
}
|
|
||||||
if (connection.AdultDayAccess) {
|
|
||||||
logic->IsAdult = true;
|
|
||||||
logic->AtDay = true;
|
|
||||||
|
|
||||||
const auto& eval = EvaluateExpression(connection.ExpressionTable.Root.Expression);
|
|
||||||
PopulateExpressionValues(connection.ExpressionTable.Root, eval, AgeTime::AdultDay);
|
|
||||||
|
|
||||||
logic->IsAdult = false;
|
|
||||||
logic->AtDay = false;
|
|
||||||
}
|
|
||||||
if (connection.AdultNightAccess) {
|
|
||||||
logic->IsAdult = true;
|
|
||||||
logic->AtNight = true;
|
|
||||||
|
|
||||||
const auto& eval = EvaluateExpression(connection.ExpressionTable.Root.Expression);
|
|
||||||
PopulateExpressionValues(connection.ExpressionTable.Root, eval, AgeTime::AdultNight);
|
|
||||||
|
|
||||||
logic->IsAdult = false;
|
|
||||||
logic->AtNight = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto [combineAll, combineChild, combineAdult] = CalculateCombines(connection.ExpressionTable.Root);
|
|
||||||
connection.ExpressionTable.CombineAll = combineAll;
|
|
||||||
connection.ExpressionTable.CombineChild = combineChild;
|
|
||||||
connection.ExpressionTable.CombineAdult = combineAdult;
|
|
||||||
|
|
||||||
node.Connections.emplace_back(std::move(connection));
|
node.Connections.emplace_back(std::move(connection));
|
||||||
}
|
}
|
||||||
|
@ -449,8 +408,10 @@ 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:");
|
ImGui::TextUnformatted("Parent Access:");
|
||||||
if (ImGui::BeginTable(("##" + connection.ParentName).c_str(), 4,
|
if (ImGui::BeginTable("", 4,
|
||||||
ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoHostExtendX)) {
|
ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoHostExtendX)) {
|
||||||
ImGui::TableSetupColumn("Child Day", ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("Child Day", ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupColumn("Child Night", ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("Child Night", ImGuiTableColumnFlags_WidthFixed);
|
||||||
|
@ -481,7 +442,7 @@ static void DrawNodeConnection(LogicTrackerNode& node, LogicTrackerNode::Connect
|
||||||
|
|
||||||
if (connection.ParentRandomizerRegion != RR_NONE) {
|
if (connection.ParentRandomizerRegion != RR_NONE) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(("Show Region Logic##" + connection.ParentName).c_str())) {
|
if (ImGui::Button("Show Region Logic")) {
|
||||||
while (nodes.back().NodeId > node.NodeId) {
|
while (nodes.back().NodeId > node.NodeId) {
|
||||||
nodes.pop_back();
|
nodes.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -492,9 +453,13 @@ static void DrawNodeConnection(LogicTrackerNode& node, LogicTrackerNode::Connect
|
||||||
|
|
||||||
ImGui::TextUnformatted("Node Access:");
|
ImGui::TextUnformatted("Node Access:");
|
||||||
DrawExpressionTable(connection.ExpressionTable);
|
DrawExpressionTable(connection.ExpressionTable);
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawNode(LogicTrackerNode& node) {
|
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);
|
||||||
}
|
}
|
||||||
|
@ -510,6 +475,8 @@ static void DrawNode(LogicTrackerNode& node) {
|
||||||
}
|
}
|
||||||
ImGui::Unindent(25.0f);
|
ImGui::Unindent(25.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicTrackerWindow::DrawElement() {
|
void LogicTrackerWindow::DrawElement() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue