-
Notifications
You must be signed in to change notification settings - Fork 435
Support token editing within GraphEditor UI #2943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 16 commits
019edba
cc15276
3709caf
18b0081
ee565f7
090bf5c
b526ec7
7e81ef7
b3cee30
04f9d02
8d0767b
33fe3a7
3644bd6
0a6f9e5
7e9717e
74b237a
67130cd
3bc659e
360fcb5
2f41f79
21b7828
6bb8add
e2e2126
400f793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,65 @@ mx::NodeGraphPtr UiNode::getNodeGraph() const | |
| return _element ? _element->asA<mx::NodeGraph>() : nullptr; | ||
| } | ||
|
|
||
| void UiNode::buildUiTokenMap() | ||
| { | ||
| _uiTokenMap.clear(); // Assume we want clean slate | ||
|
|
||
| mx::ElementPtr currElem = getNode(); | ||
| while (currElem) | ||
| { | ||
| if (mx::ConstInterfaceElementPtr interfaceElem = currElem->asA<mx::InterfaceElement>()) | ||
| { | ||
| UiToken::applyTokenMapping(&_uiTokenMap, interfaceElem, currElem); | ||
|
|
||
| // If the node is a nodegraph, check for tokens on corresponding nodedef | ||
| if (mx::ConstNodeGraphPtr nodegraph = currElem->asA<mx::NodeGraph>()) | ||
| { | ||
| if (mx::NodeDefPtr nodedef = nodegraph->getNodeDef()) | ||
| UiToken::applyTokenMapping(&_uiTokenMap, nodedef, nodedef); | ||
| } | ||
|
|
||
| // If the node is a custom node instance, check for tokens on corresponding nodedef | ||
| if (mx::NodePtr node = currElem->asA<mx::Node>()) | ||
| { | ||
| if (mx::NodeDefPtr nodedef = node->getNodeDef()) | ||
| UiToken::applyTokenMapping(&_uiTokenMap, nodedef, nodedef); | ||
| } | ||
| } | ||
| currElem = currElem->getParent(); | ||
| } | ||
|
|
||
| // Traverse through inputs and determine which tokens their value depends on | ||
| for (const auto& input : getNode()->getActiveInputs()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies, as I should have caught this in my earlier review, but I believe we need a null check for this call to Since you're storing the return value of For example, this might look like the following: |
||
| { | ||
| if (input->getType() != "filename") | ||
| continue; | ||
|
|
||
| mx::StringResolverPtr inputResolver = input->createStringResolver(); | ||
| const mx::StringMap& inputTokens = inputResolver->getFilenameSubstitutions(); | ||
|
|
||
| mx::StringMap inputTokensRenormalized; | ||
| for (const auto& entry : inputTokens) | ||
| { | ||
| // Store tokens without excess delimiters | ||
| inputTokensRenormalized[entry.first] = entry.first.substr(1, entry.first.size() - 2); | ||
| } | ||
|
|
||
| std::string inputValue = input->getValueString(); | ||
| if (inputValue.empty() && input->hasInterfaceName()) | ||
| inputValue = input->getInterfaceInput()->getValueString(); // Get value from referenced interface | ||
|
|
||
| for (const auto& entry : inputTokens) | ||
| { | ||
| if (inputValue.find(entry.first) != std::string::npos) | ||
| { | ||
| // Append to affected inputs of corresponding entry in token map | ||
| _uiTokenMap[inputTokensRenormalized[entry.first]]->addAffectedInput(input); | ||
|
jstone-lucasfilm marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // return the uiNode connected with input name | ||
| UiNodePtr UiNode::getConnectedNode(const std::string& name) | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.