Game Development Reference
In-Depth Information
When an actor in the actor list is clicked, the editor needs to show its properties and
allow them to be changed. That is the job of the class you ' ll see next, the ActorCom-
ponentEditor . It is informed of the selected actor with a method that is hooked
into the AfterSelect event of the actor TreeView.
private void TreeView_Actors_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode node = TreeView_Actors.SelectedNode;
if (node != null)
{
m_SelectedActorId = node.Index + 1; // Game starts Actor Ids at 1
m_ActorComponentEditor.ShowActorComponents(
m_SelectedActorId, GetActorXml(m_SelectedActorId));
}
}
The Menu Bar
The EditorForm has a menu bar attached, which is used for all manner of editor
functions. Making these functions work is a matter of hooking up a method to each
menu item through the C# Windows Forms Designer. Double-clicking on any menu
item automatically jumps to the handler code or adds it if it doesn ' t exist. Not every
method of the editor
s menu bar will be discussed here, as many of them are
extremely simple. Three worth mentioning are for opening a level, saving a level,
and building the project.
'
private void openLevelToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.InitialDirectory = m_AssetsDirectory +
\\World
;
j
dialog.Filter =
XML files (*.xml)
*.xml
;
dialog.FilterIndex = 1;
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
string fileName = dialog.FileName;
NativeMethods.OpenLevel(fileName);
InitializeActors();
}
}
Opening a level is actually done by the C++ DLL. Once the level load is complete,
InitializeActors() will reinitialize the actor list.
 
Search WWH ::




Custom Search