MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ReplaceWithQueryNode

Method ReplaceWithQueryNode

editor/DallasMainDlg.cpp:13920–13977  ·  view source on GitHub ↗

Replaces the currently selected node with a new query

Source from the content-addressed store, hash-verified

13918
13919// Replaces the currently selected node with a new query
13920void CDallasMainDlg::ReplaceWithQueryNode(int query_ID) {
13921 HTREEITEM selected_node, new_query_node;
13922 tTreeNodeData *data;
13923 int query_return_type;
13924 CString query_return_name;
13925
13926 // Check the ID validity
13927 if (query_ID < 0 || query_ID >= MAX_QUERIES)
13928 return;
13929
13930 // Obtain the currently selected node
13931 selected_node = m_ScriptTree.GetSelectedItem();
13932 if (selected_node == NULL)
13933 return;
13934
13935 // Get the node's data
13936 data = (tTreeNodeData *)m_ScriptTree.GetItemData(selected_node);
13937 if (data == NULL)
13938 return;
13939
13940 // Make sure this node is valid for adding a query
13941 if (data->type == EXPRESSION_NODE || data->type == PARAMETER_NODE) {
13942 tTreeNodeData node_data;
13943
13944 // Fill in the data appropriately for the new query node
13945 node_data.type = EXPRESSION_NODE;
13946 node_data.ID = query_ID;
13947
13948 query_return_type = GetQueryReturnType(query_ID, query_return_name);
13949 if (query_return_type == ENUM_PARAMETER_TYPE || query_return_type == FLAG_PARAMETER_TYPE)
13950 strcpy(node_data.name, query_return_name.GetBuffer(0));
13951 else if (GetNodeType(m_ScriptTree.GetParentItem(selected_node)) == CONDITIONAL_STATEMENT_NODE)
13952 strcpy(node_data.name, GetLiteralName(query_return_type));
13953 else
13954 strcpy(node_data.name, data->name);
13955
13956 // Add new query node before current node, then delete the current node
13957 new_query_node = AddNodeToTree(m_ScriptTree.GetParentItem(selected_node), selected_node, &node_data, TRUE);
13958
13959 // Add in the parameters with appropriate defaults
13960 AddQueryParameterNodes(new_query_node);
13961
13962 // Now delete the selected item tree
13963 m_ScriptTree.SelectItem(new_query_node);
13964 FreeTreeItem(selected_node);
13965
13966 // Update the new query node's text to include the parameters
13967 UpdateAllParentNodesText(new_query_node);
13968
13969 // If this node is the first of a comparison conditional, make sure third node's type matches
13970 DoComparisonMatchup(new_query_node);
13971
13972 if (new_query_node != NULL)
13973 m_ScriptTree.Expand(new_query_node, TVE_EXPAND);
13974
13975 SetModified(TRUE);
13976 }
13977}

Callers

nothing calls this directly

Calls 3

GetBufferMethod · 0.80
GetSelectedItemMethod · 0.45
SelectItemMethod · 0.45

Tested by

no test coverage detected