def humUnits = ['footman','gryphonrider','knight','peasant','priest','rifleman','seigeengine','sorceress','spellbreaker','summonwaterelemental','dragonhawk','flyingmachine','mortarteam'] def orcUnits = ['wyvernrider','demolisher','grunt','headhunter','kotobeast','peon','raider','shaman','spiritwalker','spiritwolf','tauren','trollbatrider','witchdoctor'] def neUnits = ['mountaingiant','wisp','archer','chimaera','druidoftheclaw','druidofthetalon','dryad','faeriedragon','glaivethrower','hippogriff','huntress'] def udUnits = ['shade','abomination','acolyte','banshee','cryptfiend','frostwyrm','gargoyle','ghoul','meatwagon','necromancer','obsidianstatue','destroyer'] def units = [ne:neUnits,hum:humUnits,orc:orcUnits,ud:udUnits] def content = "" units.each{k,v-> def unitRows = "" def race = k v.each{ def unitName = it def unitRow = """<TableRow android:layout_marginBottom="5dip" ><ImageView android:src="@drawable/${unitName}" style="@style/iconStyle"/> <com.jleo.war3.SoundingButton android:text="Ready" wsb:soundSrc="@raw/archerready1" style="@style/${race}ButtonStyle"/> <com.jleo.war3.SoundingButton android:text="What" wsb:soundSrc="@raw/archerready1" style="@style/${race}ButtonStyle"/> <com.jleo.war3.SoundingButton android:text="Yes" wsb:soundSrc="@raw/archerready1" style="@style/${race}ButtonStyle"/> <com.jleo.war3.SoundingButton android:text="Death" wsb:soundSrc="@raw/archerready1" style="@style/${race}ButtonStyle"/> <com.jleo.war3.SoundingButton android:text="Pissed" wsb:soundSrc="@raw/archerready1" style="@style/${race}ButtonStyle"/></TableRow>""" unitRows += unitRow } def id if(k.equals('hum')) id = "human" if(k.equals('orc')) id = "orc" if(k.equals('ud')) id = "undead" if(k.equals('ne')) id = "nightElf" def template = """<ScrollView android:padding="10dip" android:id="@+id/${id}" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="none"><TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="0" android:background="@drawable/nebg"> ${unitRows} </TableLayout></ScrollView> """ content += template } new File("c:\\content.xml").write(content)