mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 05:13:39 -07:00
Calculate Show Randomizer Checks/Regions before drawing each frame. Remove nodes after showing a region.
This commit is contained in:
parent
656443e7a1
commit
1b75b5ef87
1 changed files with 45 additions and 5 deletions
|
@ -155,8 +155,18 @@ static void PopulateConnectionExpression(LogicTrackerNode::Connection& connectio
|
||||||
connection.ExpressionTable.CombineAdult = combineAdult;
|
connection.ExpressionTable.CombineAdult = combineAdult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RandomizerCheck showRandomizerCheck = RC_UNKNOWN_CHECK;
|
||||||
|
|
||||||
void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
const auto& location = Rando::StaticData::GetLocation(randomizerCheck);
|
showRandomizerCheck = randomizerCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CalculateShowRandomizerCheck() {
|
||||||
|
if (showRandomizerCheck == RC_UNKNOWN_CHECK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& location = Rando::StaticData::GetLocation(showRandomizerCheck);
|
||||||
|
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
|
|
||||||
|
@ -167,7 +177,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
||||||
const auto& region = areaTable[randomizerRegion];
|
const auto& region = areaTable[randomizerRegion];
|
||||||
for (const auto& locationAccess : region.locations) {
|
for (const auto& locationAccess : region.locations) {
|
||||||
if (locationAccess.GetLocation() == randomizerCheck) {
|
if (locationAccess.GetLocation() == showRandomizerCheck) {
|
||||||
LogicTrackerNode::Connection connection;
|
LogicTrackerNode::Connection connection;
|
||||||
connection.ParentName = "Region: " + region.regionName;
|
connection.ParentName = "Region: " + region.regionName;
|
||||||
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
||||||
|
@ -189,19 +199,33 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
||||||
window->Show();
|
window->Show();
|
||||||
ImGui::SetWindowFocus(window->GetName().c_str());
|
ImGui::SetWindowFocus(window->GetName().c_str());
|
||||||
expandNodeId = node.NodeId;
|
expandNodeId = node.NodeId;
|
||||||
|
|
||||||
|
showRandomizerCheck = RC_UNKNOWN_CHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RandomizerRegion showToRandomizerRegion = RR_NONE;
|
||||||
|
RandomizerRegion showFromRandomizerRegion = RR_NONE;
|
||||||
|
|
||||||
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegion,
|
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegion,
|
||||||
RandomizerRegion fromRandomizerRegion) {
|
RandomizerRegion fromRandomizerRegion) {
|
||||||
const auto& region = RegionTable(toRandomizerRegion);
|
showToRandomizerRegion = toRandomizerRegion;
|
||||||
|
showFromRandomizerRegion = fromRandomizerRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CalculateShowRandomizerRegion() {
|
||||||
|
if (showToRandomizerRegion == RR_NONE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& region = RegionTable(showToRandomizerRegion);
|
||||||
|
|
||||||
LogicTrackerNode node;
|
LogicTrackerNode node;
|
||||||
node.NodeName = "Region: " + region->regionName;
|
node.NodeName = "Region: " + region->regionName;
|
||||||
node.NodeId = nodes.size();
|
node.NodeId = nodes.size();
|
||||||
node.RandomizerRegion = toRandomizerRegion;
|
node.RandomizerRegion = showToRandomizerRegion;
|
||||||
|
|
||||||
for (const auto& entrance : region->entrances) {
|
for (const auto& entrance : region->entrances) {
|
||||||
if (entrance->GetParentRegionKey() == fromRandomizerRegion) {
|
if (entrance->GetParentRegionKey() == showFromRandomizerRegion) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +250,9 @@ void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegio
|
||||||
window->Show();
|
window->Show();
|
||||||
ImGui::SetWindowFocus(window->GetName().c_str());
|
ImGui::SetWindowFocus(window->GetName().c_str());
|
||||||
expandNodeId = node.NodeId;
|
expandNodeId = node.NodeId;
|
||||||
|
|
||||||
|
showToRandomizerRegion = RR_NONE;
|
||||||
|
showFromRandomizerRegion = RR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string ToString(const std::optional<LogicExpression::ValueVariant>& value) {
|
static std::string ToString(const std::optional<LogicExpression::ValueVariant>& value) {
|
||||||
|
@ -508,6 +535,8 @@ static std::string GetAvailableString(const LogicTrackerNode::Connection& connec
|
||||||
return available;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int clearNodesAfterNodeID = -1;
|
||||||
|
|
||||||
static void DrawNode(LogicTrackerNode& node) {
|
static void DrawNode(LogicTrackerNode& node) {
|
||||||
ImGui::PushID(node.NodeId);
|
ImGui::PushID(node.NodeId);
|
||||||
|
|
||||||
|
@ -549,6 +578,7 @@ static void DrawNode(LogicTrackerNode& node) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(ICON_FA_COGS)) {
|
if (ImGui::Button(ICON_FA_COGS)) {
|
||||||
LogicTrackerWindow::ShowRandomizerRegion(connection.ParentRandomizerRegion, node.RandomizerRegion);
|
LogicTrackerWindow::ShowRandomizerRegion(connection.ParentRandomizerRegion, node.RandomizerRegion);
|
||||||
|
clearNodesAfterNodeID = node.NodeId;
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip("Show Region Logic");
|
ImGui::SetTooltip("Show Region Logic");
|
||||||
|
@ -568,6 +598,9 @@ static void DrawNode(LogicTrackerNode& node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicTrackerWindow::DrawElement() {
|
void LogicTrackerWindow::DrawElement() {
|
||||||
|
CalculateShowRandomizerCheck();
|
||||||
|
CalculateShowRandomizerRegion();
|
||||||
|
|
||||||
if (expandNodeId != -1) {
|
if (expandNodeId != -1) {
|
||||||
expandingNode = true;
|
expandingNode = true;
|
||||||
}
|
}
|
||||||
|
@ -580,6 +613,13 @@ void LogicTrackerWindow::DrawElement() {
|
||||||
expandNodeId = -1;
|
expandNodeId = -1;
|
||||||
expandingNode = false;
|
expandingNode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clearNodesAfterNodeID != -1) {
|
||||||
|
while (nodes.back().NodeId > clearNodesAfterNodeID) {
|
||||||
|
nodes.pop_back();
|
||||||
|
}
|
||||||
|
clearNodesAfterNodeID = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicTrackerWindow::InitElement() {
|
void LogicTrackerWindow::InitElement() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue