mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -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;
|
||||
}
|
||||
|
||||
RandomizerCheck showRandomizerCheck = RC_UNKNOWN_CHECK;
|
||||
|
||||
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();
|
||||
|
||||
|
@ -167,7 +177,7 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
|||
for (int randomizerRegion = RR_NONE; randomizerRegion < RR_MAX; ++randomizerRegion) {
|
||||
const auto& region = areaTable[randomizerRegion];
|
||||
for (const auto& locationAccess : region.locations) {
|
||||
if (locationAccess.GetLocation() == randomizerCheck) {
|
||||
if (locationAccess.GetLocation() == showRandomizerCheck) {
|
||||
LogicTrackerNode::Connection connection;
|
||||
connection.ParentName = "Region: " + region.regionName;
|
||||
connection.ParentRandomizerRegion = RandomizerRegion(randomizerRegion);
|
||||
|
@ -189,19 +199,33 @@ void LogicTrackerWindow::ShowRandomizerCheck(RandomizerCheck randomizerCheck) {
|
|||
window->Show();
|
||||
ImGui::SetWindowFocus(window->GetName().c_str());
|
||||
expandNodeId = node.NodeId;
|
||||
|
||||
showRandomizerCheck = RC_UNKNOWN_CHECK;
|
||||
}
|
||||
|
||||
RandomizerRegion showToRandomizerRegion = RR_NONE;
|
||||
RandomizerRegion showFromRandomizerRegion = RR_NONE;
|
||||
|
||||
void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegion,
|
||||
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;
|
||||
node.NodeName = "Region: " + region->regionName;
|
||||
node.NodeId = nodes.size();
|
||||
node.RandomizerRegion = toRandomizerRegion;
|
||||
node.RandomizerRegion = showToRandomizerRegion;
|
||||
|
||||
for (const auto& entrance : region->entrances) {
|
||||
if (entrance->GetParentRegionKey() == fromRandomizerRegion) {
|
||||
if (entrance->GetParentRegionKey() == showFromRandomizerRegion) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -226,6 +250,9 @@ void LogicTrackerWindow::ShowRandomizerRegion(RandomizerRegion toRandomizerRegio
|
|||
window->Show();
|
||||
ImGui::SetWindowFocus(window->GetName().c_str());
|
||||
expandNodeId = node.NodeId;
|
||||
|
||||
showToRandomizerRegion = RR_NONE;
|
||||
showFromRandomizerRegion = RR_NONE;
|
||||
}
|
||||
|
||||
static std::string ToString(const std::optional<LogicExpression::ValueVariant>& value) {
|
||||
|
@ -508,6 +535,8 @@ static std::string GetAvailableString(const LogicTrackerNode::Connection& connec
|
|||
return available;
|
||||
}
|
||||
|
||||
int clearNodesAfterNodeID = -1;
|
||||
|
||||
static void DrawNode(LogicTrackerNode& node) {
|
||||
ImGui::PushID(node.NodeId);
|
||||
|
||||
|
@ -549,6 +578,7 @@ static void DrawNode(LogicTrackerNode& node) {
|
|||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_COGS)) {
|
||||
LogicTrackerWindow::ShowRandomizerRegion(connection.ParentRandomizerRegion, node.RandomizerRegion);
|
||||
clearNodesAfterNodeID = node.NodeId;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Show Region Logic");
|
||||
|
@ -568,6 +598,9 @@ static void DrawNode(LogicTrackerNode& node) {
|
|||
}
|
||||
|
||||
void LogicTrackerWindow::DrawElement() {
|
||||
CalculateShowRandomizerCheck();
|
||||
CalculateShowRandomizerRegion();
|
||||
|
||||
if (expandNodeId != -1) {
|
||||
expandingNode = true;
|
||||
}
|
||||
|
@ -580,6 +613,13 @@ void LogicTrackerWindow::DrawElement() {
|
|||
expandNodeId = -1;
|
||||
expandingNode = false;
|
||||
}
|
||||
|
||||
if (clearNodesAfterNodeID != -1) {
|
||||
while (nodes.back().NodeId > clearNodesAfterNodeID) {
|
||||
nodes.pop_back();
|
||||
}
|
||||
clearNodesAfterNodeID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void LogicTrackerWindow::InitElement() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue