Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Exporters/WarFoundryHtmlExporter.cs @ 203:df4e56e2ee71
Re #208: equipment slot issues
* Consolidate some code in to one line
* Make min/max percentage methods get the min/max of the calculated percentage and the percentage based on the numeric limit to ensure percentage is never greater than or less than (as appropriate) the numeric limit
Also:
* Remove Math.Min and Math.Max calls from Min/Max equipment count methods - we're assuming min < max in the percentages, so assume it here as well
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 06 Nov 2009 20:48:07 +0000 |
parents | 91f7b8da0b53 |
children | e8e9026dd4ea |
rev | line source |
---|---|
130
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (WarFoundryHtmlExporter.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
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. |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
6 using System.Collections.Generic; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
7 using System.IO; |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
8 using System.Text; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
9 using System.Xml; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
10 using System.Xml.Schema; |
164 | 11 using IBBoard.Lang; |
163
395c8042dc03
Fixes #144: HTML generation may need network connection
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
12 using IBBoard.Xml; |
130
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 using IBBoard.WarFoundry.API.Objects; |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 namespace IBBoard.WarFoundry.API.Exporters |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 /// <summary> |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 /// Custom exporter that exports an army as a basic HTML file |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 /// </summary> |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 public class WarFoundryHtmlExporter : IWarFoundryExporter |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 private static WarFoundryHtmlExporter exporter; |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 public static WarFoundryHtmlExporter GetDefault() |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 if (exporter == null) |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 exporter = new WarFoundryHtmlExporter(); |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 return exporter; |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 private WarFoundryHtmlExporter() |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 //Hide constructor |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 public void ExportArmy(Army army, string path) |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 { |
164 | 41 XmlDocument doc = new XmlDocument(); |
42 CustomXmlResolver resolver = new CustomXmlResolver(); | |
43 resolver.AddMapping("-//W3C//DTD XHTML 1.0 Strict//EN", new Uri("file://" + IBBoard.Constants.ExecutablePath + "/dtds/xhtml1-strict.dtd")); | |
163
395c8042dc03
Fixes #144: HTML generation may need network connection
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
44 doc.XmlResolver = resolver; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
45 doc.AppendChild(doc.CreateDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", null)); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
46 XmlElement html = doc.CreateElement("html"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
47 doc.AppendChild(html); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
48 XmlElement head = doc.CreateElement("head"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
49 html.AppendChild(head); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
50 XmlElement title = doc.CreateElement("title"); |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
51 title.InnerXml = army.Name; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
52 head.AppendChild(title); |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
53 XmlElement style = doc.CreateElement("style"); |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
54 style.InnerText = "table, th, td { border: 1px solid #000 }"; |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
55 head.AppendChild(style); |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
56 XmlElement body = doc.CreateElement("body"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
57 html.AppendChild(body); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
58 XmlElement header = doc.CreateElement("h1"); |
143
7f13ffcb8765
Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents:
134
diff
changeset
|
59 header.InnerText = Translation.GetTranslation("armyHtmlOutputBodyHeader", "{0} - {1}pts", army.Name, army.Points); |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
60 body.AppendChild(header); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
61 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
62 foreach (XmlElement table in CreateTables(army, doc)) |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
63 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
64 if (!IsTableOnlyHeader(table)) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
65 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
66 body.AppendChild(table); |
153
dd892567f054
Fixes #174: HTML output can add empty tables for stat lines
IBBoard <dev@ibboard.co.uk>
parents:
143
diff
changeset
|
67 } |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
68 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
69 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
70 StreamWriter writer = new StreamWriter(path, false); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
71 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
72 try |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
73 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
74 writer.Write(doc.OuterXml); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
75 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
76 finally |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
77 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
78 writer.Close(); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
79 } |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
80 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
81 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
82 private bool IsTableOnlyHeader(XmlElement table) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
83 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
84 return table.ChildNodes.Count == 1; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
85 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
86 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
87 private XmlElement[] CreateTables(Army army, XmlDocument doc) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
88 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
89 Dictionary<string, XmlElement> tables = new Dictionary<string, XmlElement>(); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
90 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
91 foreach (SystemStats statSets in army.GameSystem.SystemStats) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
92 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
93 tables[statSets.ID] = CreateTable(statSets, doc); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
94 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
95 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
96 foreach (Unit unit in army.GetUnits()) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
97 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
98 tables[unit.UnitType.StatsID].AppendChild(CreateUnitRow(unit, doc)); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
99 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
100 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
101 return DictionaryUtils.ToArray(tables); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
102 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
103 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
104 private XmlElement CreateTable(SystemStats stats, XmlDocument doc) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
105 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
106 XmlElement table = doc.CreateElement("table"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
107 XmlElement headerRow = doc.CreateElement("tr"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
108 table.AppendChild(headerRow); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
109 XmlElement name = doc.CreateElement("th"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
110 name.InnerText = "Name"; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
111 headerRow.AppendChild(name); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
112 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
113 foreach (StatSlot stat in stats.StatSlots) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
114 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
115 XmlElement statHeader = doc.CreateElement("th"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
116 statHeader.InnerText = stat.Name; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
117 headerRow.AppendChild(statHeader); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
118 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
119 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
120 XmlElement notes = doc.CreateElement("th"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
121 notes.InnerText = "Notes"; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
122 headerRow.AppendChild(notes); |
132 | 123 |
124 XmlElement points = doc.CreateElement("th"); | |
125 points.InnerText = "Points"; | |
126 headerRow.AppendChild(points); | |
127 | |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
128 return table; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
129 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
130 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
131 private XmlElement CreateUnitRow(Unit unit, XmlDocument doc) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
132 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
133 XmlElement row = doc.CreateElement("tr"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
134 XmlElement name = doc.CreateElement("td"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
135 name.InnerText = unit.Name; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
136 row.AppendChild(name); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
137 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
138 foreach (Stat stat in unit.UnitStatsArray) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
139 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
140 XmlElement statCell = doc.CreateElement("td"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
141 statCell.InnerText = stat.SlotValueString; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
142 row.AppendChild(statCell); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
143 } |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
144 |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
145 StringBuilder sb = new StringBuilder(); |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
146 bool addSeparator = false; |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
147 |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
148 foreach (UnitEquipmentItem equip in unit.GetEquipment()) |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
149 { |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
150 if (!addSeparator) |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
151 { |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
152 addSeparator = true; |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
153 } |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
154 else |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
155 { |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
156 sb.Append(", "); |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
157 } |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
158 |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
159 sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, unit.GetEquipmentAmountString(equip))); |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
160 } |
132 | 161 |
162 XmlElement notes = doc.CreateElement("td"); | |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
163 notes.InnerText = sb.ToString(); |
132 | 164 row.AppendChild(notes); |
165 | |
166 XmlElement points = doc.CreateElement("td"); | |
143
7f13ffcb8765
Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents:
134
diff
changeset
|
167 points.InnerText = unit.Points.ToString(); |
132 | 168 row.AppendChild(points); |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
169 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
170 return row; |
130
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 } |