comparison api/Exporters/WarFoundryHtmlExporter.cs @ 134:57f7b80757ea

Re #68: Export army to another format * Add styling to table * Add in text for equipment * Add method to Unit to get equipment amount strings * Refactor unit equipment handling to reduce duplication
author IBBoard <dev@ibboard.co.uk>
date Tue, 01 Sep 2009 18:56:38 +0000
parents e9c415839462
children 7f13ffcb8765
comparison
equal deleted inserted replaced
133:a6d1cc17ec33 134:57f7b80757ea
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. 3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
4 4
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using System.Text;
8 using System.Xml; 9 using System.Xml;
9 using System.Xml.Schema; 10 using System.Xml.Schema;
10 using IBBoard.Lang; 11 using IBBoard.Lang;
11 using IBBoard.WarFoundry.API.Objects; 12 using IBBoard.WarFoundry.API.Objects;
12 13
41 XmlElement html = doc.CreateElement("html"); 42 XmlElement html = doc.CreateElement("html");
42 doc.AppendChild(html); 43 doc.AppendChild(html);
43 XmlElement head = doc.CreateElement("head"); 44 XmlElement head = doc.CreateElement("head");
44 html.AppendChild(head); 45 html.AppendChild(head);
45 XmlElement title = doc.CreateElement("title"); 46 XmlElement title = doc.CreateElement("title");
47 title.InnerXml = army.Name;
46 head.AppendChild(title); 48 head.AppendChild(title);
47 title.InnerXml = army.Name; 49 XmlElement style = doc.CreateElement("style");
50 style.InnerText = "table, th, td { border: 1px solid #000 }";
51 head.AppendChild(style);
48 XmlElement body = doc.CreateElement("body"); 52 XmlElement body = doc.CreateElement("body");
49 html.AppendChild(body); 53 html.AppendChild(body);
50 XmlElement header = doc.CreateElement("h1"); 54 XmlElement header = doc.CreateElement("h1");
51 header.InnerText = Translation.GetTranslation("armyHtmlOutputBodyHeader", "{0} - {1}pts", army.Name, army.PointsTotal); 55 header.InnerText = Translation.GetTranslation("armyHtmlOutputBodyHeader", "{0} - {1}pts", army.Name, army.PointsTotal);
52 body.AppendChild(header); 56 body.AppendChild(header);
123 { 127 {
124 XmlElement statCell = doc.CreateElement("td"); 128 XmlElement statCell = doc.CreateElement("td");
125 statCell.InnerText = stat.SlotValueString; 129 statCell.InnerText = stat.SlotValueString;
126 row.AppendChild(statCell); 130 row.AppendChild(statCell);
127 } 131 }
132
133 StringBuilder sb = new StringBuilder();
134 bool addSeparator = false;
135
136 foreach (UnitEquipmentItem equip in unit.GetEquipment())
137 {
138 if (!addSeparator)
139 {
140 addSeparator = true;
141 }
142 else
143 {
144 sb.Append(", ");
145 }
146
147 sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, unit.GetEquipmentAmountString(equip)));
148 }
128 149
129 XmlElement notes = doc.CreateElement("td"); 150 XmlElement notes = doc.CreateElement("td");
130 notes.InnerText = "TODO: Notes here (equipment etc)"; 151 notes.InnerText = sb.ToString();
131 row.AppendChild(notes); 152 row.AppendChild(notes);
132 153
133 XmlElement points = doc.CreateElement("td"); 154 XmlElement points = doc.CreateElement("td");
134 points.InnerText = unit.PointsValue.ToString(); 155 points.InnerText = unit.PointsValue.ToString();
135 row.AppendChild(points); 156 row.AppendChild(points);