diff 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
line wrap: on
line diff
--- a/api/Exporters/WarFoundryHtmlExporter.cs	Tue Sep 01 18:21:27 2009 +0000
+++ b/api/Exporters/WarFoundryHtmlExporter.cs	Tue Sep 01 18:56:38 2009 +0000
@@ -5,6 +5,7 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Text;
 using System.Xml;
 using System.Xml.Schema;
 using IBBoard.Lang;
@@ -43,8 +44,11 @@
 			XmlElement head = doc.CreateElement("head");
 			html.AppendChild(head);
 			XmlElement title = doc.CreateElement("title");
+			title.InnerXml = army.Name;
 			head.AppendChild(title);
-			title.InnerXml = army.Name;
+			XmlElement style = doc.CreateElement("style");
+			style.InnerText = "table, th, td { border: 1px solid #000 }";
+			head.AppendChild(style);
 			XmlElement body = doc.CreateElement("body");
 			html.AppendChild(body);
 			XmlElement header = doc.CreateElement("h1");
@@ -125,9 +129,26 @@
 				statCell.InnerText = stat.SlotValueString;
 				row.AppendChild(statCell);
 			}
+
+			StringBuilder sb = new StringBuilder();
+			bool addSeparator = false;
+
+			foreach (UnitEquipmentItem equip in unit.GetEquipment())
+			{
+				if (!addSeparator)
+				{
+					addSeparator = true;
+				}
+				else
+				{
+					sb.Append(", ");
+				}
+
+				sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, unit.GetEquipmentAmountString(equip)));
+			}
 						
 			XmlElement notes = doc.CreateElement("td");
-			notes.InnerText = "TODO: Notes here (equipment etc)";
+			notes.InnerText = sb.ToString();
 			row.AppendChild(notes);
 			
 			XmlElement points = doc.CreateElement("td");