Game Development Reference
In-Depth Information
MessageBox.Show(
Error - This file isn
'
t a part of this
+
project (it must be in
+ m_AssetsDirectory +
).
);
}
}
catch
{
MessageBox.Show(
ElementName is incorrect in SelectFile
);
}
}
}
This code would get run anytime a button associated with a file element is pressed.
The first order of business is to find the actual name of the text box control. Since the
button has the same name as its companion text box control, with
added to
the end, a call to Substring() quickly finds the text box name. Later on, this string
will be used to find the actual control by accessing m_Panel.Controls with the
name of the text box. Since this is a file element, it is important to find the allowed
extensions for the file. In the case of a texture file, extensions might be DDS, JPG,
BMP, and so on. A helper function, FindEditorElementFromXPath() , uses the
XPath name of the control to find the XmlElement the editor uses to get hints
about how the element needs to be edited.
Button
private XmlNode FindEditorElementFromXPath(string xpath)
{
XmlNode root = m_SelectedActorComponents.FirstChild;
XmlNodeList nodeList = root.SelectNodes(xpath);
return nodeList[0];
}
Recall that the m_SelectedActorComponents member was initialized when the
actor was selected, and for each component defined in the actor, this XmlElement
received a child node from the editor
s components definition. The XPath names of
the controls map each control to the value stored in the actor and the hints to the
editor on how it is edited.
The last method in this trio is FileElementChanged() , which is called anytime
the value in the text box changes. Its job is to construct an XML string that will be
sent to the C++ EditorLogic class.
'
private void FileElementChanged(object sender, EventArgs e)
{
TextBox textBox = (TextBox)sender;
string xPath = textBox.Name;
string newValue = textBox.Text;
 
Search WWH ::




Custom Search