justin-espedal / polydes

Collection of open source Stencyl extensions.
MIT License
8 stars 4 forks source link

Structure Definition XML Extension #74

Closed justin-espedal closed 9 years ago

justin-espedal commented 9 years ago

Allow a basic level of extension of the xml format used to store structure definitions.

For some Stencyl extension with the unique identifier com.example.extension, allow an xml element of the same name to be processed by that extension.

<structure>
  <com.example.extension>
    ...
  </com.example.extension>
  <field ... />
  <field ... />
</structure>
justin-espedal commented 9 years ago

Use case for Dialog Extension:

Each dialog plugin (as data structure definitions) should have a field pointing to a DialogExtension.

<structure>
  <com.polydes.dialog>
    <implementation class="dialog.ext.CharacterScripts"/>
  </com.polydes.dialog>
  <field ... />
  <field ... />
</structure>
justin-espedal commented 9 years ago

I ended up going with xml namespaces to tell the definition reader to ask an extension to read an element.

<dg:extension implementation="dialog.ext.CharacterScripts" xmlns:dg="com.polydes.dialog">
    <dg:cmds>
        <dg:cmd name="showname">
            <dg:arg name="name" type="String" />
        </dg:cmd>
        <dg:cmd name="hidename" />
        <dg:cmd name="face">
            <dg:arg name="image" type="String" />
        </dg:cmd>
    </dg:cmds>
    <dg:drawkeys>
        <dg:drawkey name="Namebox" />
        <dg:drawkey name="Face" />
    </dg:drawkeys>
</dg:extension>
justin-espedal commented 9 years ago

Began with 18705c5108f870871f9dde932c0b024ecb18bc02 Finished with 89071ad4ffb501946ecd896c973400caf19e9833

Dialog implementation added in a12796badbf8d35784e08c0ab3ba015e78bcdbaf