Game Development Reference
In-Depth Information
Each component definition has a name and multiple elements. Each element has a
name, a type, and optional attributes that the editor will use when creating dynamic
controls. For example, the file type needs to know what kinds of extensions are legal
for the file. Each component definition exactly mirrors the component definitions in
the actor XML files. For example, here is a partial definition for the Grid actor:
<Actor type=
>
<TransformComponent>
<Position x=
Grid
/>
<YawPitchRoll x=“0” y=“0” z=“0”/>
</TransformComponent>
<GridRenderComponent>
<Color r=“0.4” g=“0.4” b=“0.4” a=“1.0”/>
<Texture>art\grid.dds</Texture>
<Division>100</Division>
</GridRenderComponent>
<!--other components follow! -->
</Actor>
0
y=
0
z=
0
The ActorComponentsEditor could then read each component
s definition and
know exactly what controls to create so each component could be edited. Then the
only time the editor must be changed is when a new data type is introduced.
'
Keep the Game and Editor in Sync
You can try very hard to limit dependencies between the game and the editor,
but there will inevitably be a few. Even though the components and elements
are defined as XML data for the editor to read, there are still dependencies on
the existence of the components in C++, how their XML is structured, and
more. When this type of dependency is inevitable, it makes good sense to put
comments in the C++ and C# code specifying exactly how to keep the editor
and the game in perfect harmony.
Data Members and Initialization
The ActorComponentEditor has data members that keep track of the component
s
definition, the selected actor, and the C# Windows Form, a Panel, that will contain
the dynamically created controls.
'
class ActorComponentEditor
{
Dictionary<string, XmlNode> m_ComponentsByName;
XmlDocument m_SelectedActorComponents;
int m_SelectedActorId;
 
Search WWH ::




Custom Search