Added ability to set starting node

This commit is contained in:
Kah Wei 2023-03-07 19:00:10 +08:00
parent 493f2c3cfe
commit 6d01bd0b78
2 changed files with 20 additions and 2 deletions

View File

@ -305,7 +305,10 @@ namespace SHADE
ImGui::BeginDisabled(ImNodes::NumSelectedNodes() != 1); ImGui::BeginDisabled(ImNodes::NumSelectedNodes() != 1);
if (ImGui::Button(std::format("{} Set Starting Node", ICON_MD_HOME).data())) if (ImGui::Button(std::format("{} Set Starting Node", ICON_MD_HOME).data()))
{ {
// Get id of selected node
int selectedNode = 0;
ImNodes::GetSelectedNodes(&selectedNode);
controllerData->StartingNode = selectedNode; // We can do this as the ImNodes node index is the same
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
} }
@ -325,6 +328,15 @@ namespace SHADE
// Title // Title
ImNodes::BeginNodeTitleBar(); ImNodes::BeginNodeTitleBar();
{ {
// Starting node marker
if (node.Index == controllerData->StartingNode)
{
const float INDENT = NODE_WIDTH * 0.6f;
ImGui::Indent(INDENT);
ImGui::Text(ICON_MD_HOME);
ImGui::Unindent(INDENT);
}
if (node.EditingName) if (node.EditingName)
{ {
if (ImGui::Button(ICON_MD_DONE)) if (ImGui::Button(ICON_MD_DONE))
@ -749,6 +761,12 @@ namespace SHADE
} }
} }
// Mark starting node
if (nodeMap.contains(controller.GetStartingNode()))
{
data.StartingNode = nodeMap[controller.GetStartingNode()]->Index;
}
return data; return data;
} }
SHAnimationController SHAnimationControllerEditor::serialise(const AnimControllerData& data) SHAnimationController SHAnimationControllerEditor::serialise(const AnimControllerData& data)

View File

@ -100,7 +100,7 @@ namespace SHADE
struct AnimControllerData struct AnimControllerData
{ {
NodeIndex StartingNode = 0;
std::list<Node> Nodes; std::list<Node> Nodes;
std::unordered_map<std::string, SHAnimationController::AnimParam::Type> Params; std::unordered_map<std::string, SHAnimationController::AnimParam::Type> Params;
LinkMap Links; LinkMap Links;