Goomod, XSL: How to merge your own effect images into resources.xml.bin?

You are viewing a static copy of the old 2DBoy forum, which closed in 2010. It is preserved here for historical interest, but it is not possible to reply to topics. For more recent discussion about World of Goo, visit our new forum.
Goomod, XSL: How to merge your own effect images into resources.xml.bin?XDboy03/17/2009 - 22:30

Hello fellow Sign Painters,
i'm trying to get some custom particle effects installed with a goomod file, and since i have virtually no knowledge about XSL that's kinda tricky...
i managed to insert my effects in fx.xml.bin by copying the fx.xml.xsl from JingleBalls (they're all in one line afterwards, but thats not really a problem.^^).

The real problem is resources.xml.bin.
here is a shortened version of it:
<?xml version="1.0" encoding="UTF-8"?><ResourceManifest><br />...<br /> <Resources id="common"><br />    <!-- fonts --><br />    <!-- island icons --><br />    <Image id="IMAGE_GLOBAL_ISLAND_1_ICON" path="res/images/islandicon_1"/><br />    <Image id="IMAGE_GLOBAL_ISLAND_2_ICON" path="res/images/islandicon_2"/><br />    <Image id="IMAGE_GLOBAL_ISLAND_3_ICON" path="res/images/islandicon_3"/><br />    <Image id="IMAGE_GLOBAL_ISLAND_4_ICON" path="res/images/islandicon_4"/><br />    <Image id="IMAGE_GLOBAL_ISLAND_5_ICON" path="res/images/islandicon_5"/><br />    <Image id="IMAGE_GLOBAL_WOGC_ICON" path="res/images/islandicon_wogc"/><br />    <Image id="IMAGE_GLOBAL_WOGC_D_ICON" path="res/images/islandicon_wogcd"/><br />    <Image id="IMAGE_GLOBAL_WOGC_3D_ICON" path="res/images/islandicon_wogc3d"/><br /><br />    <!-- effects --><br />    ##################################<br />    #### here should be my images ####    <br />    ##################################<br />    <Image id="IMAGE_FX_SPARKLE1" path="res/images/fx/sparkle1"/><br />    <Image id="IMAGE_FX_SPARKLE2" path="res/images/fx/sparkle1"/><br />    <Image id="IMAGE_FX_DUST1" path="res/images/fx/fx_dust1"/><br />...<br />    <!-- global sounds --><br />    <SetDefaults path="res/sounds" idprefix="SOUND_GLOBAL_"/><br />    <Sound id="SHATTER" path="shatter"/><br />    <Sound id="DIALOG" path="popup"/><br />...<br />  </Resources><br /><br /></ResourceManifest><br />

and this is what i tried after reading a bit about xsl/xpath: (and many versions of that, but nothing changed in the target file)
<?xml version="1.0" encoding="ISO-8859-1"?><br /><xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><br /><br />  <!-- Copy everything not matched by another rule --><br />  <xsl:template match="* | comment()"><br />    <xsl:copy><br />      <xsl:copy-of select="@*"/><br />      <xsl:apply-templates/><br />    </xsl:copy><br />  </xsl:template><br /><br />  <!-- Copy my particle image resources --><br />  <xsl:template match="/ResourceManifest/Resources[@id='common']/comment()[contains(., 'effects')]"><br /><br />    <xsl:copy><br />      <xsl:copy-of select="@*"/><br />      <xsl:apply-templates/><br /><br />    <Image id="IMAGE_FX_XDB_TRAIL_1" path="res/images/fx/xdb_trail_1"/> <br />    <Image id="IMAGE_FX_XDB_TRAIL_2" path="res/images/fx/xdb_trail_2"/> <br />    <Image id="IMAGE_FX_SPARKLE_RED" path="res/images/fx/sparkle_red"/><br />    <Image id="IMAGE_FX_SPARKLE_GREEN" path="res/images/fx/sparkle_green"/><br />    <Image id="IMAGE_FX_SPARKLE_DGREEN" path="res/images/fx/sparkle_dgreen"/><br />    <Image id="IMAGE_FX_SPARKLE_YELLOW" path="res/images/fx/sparkle_yellow"/><br /><br />    </xsl:copy><br /><br />  </xsl:template><br /></xsl:transform>
help, please. it would be greatly appreciated.^^

Re: Goomod, XSL: How to merge your own effect images into resources.xml.bin?davidc03/18/2009 - 00:22

I'll try this out myself tomorrow, but my immediate thought is that you should include your own SetDefaults (just in case) and therefore you can place it anywhere. So, the copy part should become:

<br />  <xsl:template match="/ResourceManifest/Resources[@id='common']"><br />    <xsl:copy><br />      <xsl:copy-of select="@*"/><br />      <xsl:apply-templates/><br /><br />      <SetDefaults path="" idprefix=""/><br />      <Image id="IMAGE_FX_XDB_TRAIL_1" path="res/images/fx/xdb_trail_1"/> <br />      <Image id="IMAGE_FX_XDB_TRAIL_2" path="res/images/fx/xdb_trail_2"/> <br />      <Image id="IMAGE_FX_SPARKLE_RED" path="res/images/fx/sparkle_red"/><br />      <Image id="IMAGE_FX_SPARKLE_GREEN" path="res/images/fx/sparkle_green"/><br />      <Image id="IMAGE_FX_SPARKLE_DGREEN" path="res/images/fx/sparkle_dgreen"/><br />      <Image id="IMAGE_FX_SPARKLE_YELLOW" path="res/images/fx/sparkle_yellow"/><br /><br />    </xsl:copy><br />  </xsl:template><br />

-davidc

Re: Goomod, XSL: How to merge your own effect images into resources.xml.bin?XDboy03/18/2009 - 12:01

Thank You, David!
When i tried your version, WoG crashed. (but the xsl had at least written something.^^)
Then i found out that i had to actually use the path and idprefix attributes.

like this:
<SetDefaults path="res/images/fx/" idprefix="IMAGE_FX_"/><br /><Image id="XDB_TRAIL_1" path="xdb_trail_1"/><br />...

Now it works!  ;D

Off topic: Gootool 1.0 and  your level editor... http://goofans.com/node/135 ;)