Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Exporters/WarFoundryHtmlExporter.cs @ 154:4a02c07278e7
Re #185: Problems with decimals in race definitions
* Fix race factory so that it parses unit costs as doubles, not ints
Also:
* Line ending clean-up
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 28 Sep 2009 19:32:52 +0000 |
parents | dd892567f054 |
children | 395c8042dc03 |
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; |
132 | 11 using IBBoard.Lang; |
130
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 using IBBoard.WarFoundry.API.Objects; |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 namespace IBBoard.WarFoundry.API.Exporters |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 /// <summary> |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 /// 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
|
18 /// </summary> |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 public class WarFoundryHtmlExporter : IWarFoundryExporter |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 private static WarFoundryHtmlExporter exporter; |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 public static WarFoundryHtmlExporter GetDefault() |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 if (exporter == null) |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 exporter = new WarFoundryHtmlExporter(); |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 } |
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 return exporter; |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 } |
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 private WarFoundryHtmlExporter() |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 { |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 //Hide constructor |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 } |
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 public void ExportArmy(Army army, string path) |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 { |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
40 XmlDocument doc = new XmlDocument(); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
41 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
|
42 XmlElement html = doc.CreateElement("html"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
43 doc.AppendChild(html); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
44 XmlElement head = doc.CreateElement("head"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
45 html.AppendChild(head); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
46 XmlElement title = doc.CreateElement("title"); |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
47 title.InnerXml = army.Name; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
48 head.AppendChild(title); |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
49 XmlElement style = doc.CreateElement("style"); |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
50 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
|
51 head.AppendChild(style); |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
52 XmlElement body = doc.CreateElement("body"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
53 html.AppendChild(body); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
54 XmlElement header = doc.CreateElement("h1"); |
143
7f13ffcb8765
Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents:
134
diff
changeset
|
55 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
|
56 body.AppendChild(header); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
57 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
58 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
|
59 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
60 if (!IsTableOnlyHeader(table)) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
61 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
62 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
|
63 } |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
64 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
65 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
66 StreamWriter writer = new StreamWriter(path, false); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
67 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
68 try |
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 writer.Write(doc.OuterXml); |
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 finally |
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.Close(); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
75 } |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
76 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
77 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
78 private bool IsTableOnlyHeader(XmlElement table) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
79 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
153
diff
changeset
|
80 return table.ChildNodes.Count == 1; |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
81 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
82 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
83 private XmlElement[] CreateTables(Army army, XmlDocument doc) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
84 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
85 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
|
86 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
87 foreach (SystemStats statSets in army.GameSystem.SystemStats) |
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 tables[statSets.ID] = CreateTable(statSets, doc); |
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 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
92 foreach (Unit unit in army.GetUnits()) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
93 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
94 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
|
95 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
96 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
97 return DictionaryUtils.ToArray(tables); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
98 } |
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 private XmlElement CreateTable(SystemStats stats, XmlDocument doc) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
101 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
102 XmlElement table = doc.CreateElement("table"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
103 XmlElement headerRow = doc.CreateElement("tr"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
104 table.AppendChild(headerRow); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
105 XmlElement name = doc.CreateElement("th"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
106 name.InnerText = "Name"; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
107 headerRow.AppendChild(name); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
108 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
109 foreach (StatSlot stat in stats.StatSlots) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
110 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
111 XmlElement statHeader = doc.CreateElement("th"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
112 statHeader.InnerText = stat.Name; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
113 headerRow.AppendChild(statHeader); |
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 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
116 XmlElement notes = doc.CreateElement("th"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
117 notes.InnerText = "Notes"; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
118 headerRow.AppendChild(notes); |
132 | 119 |
120 XmlElement points = doc.CreateElement("th"); | |
121 points.InnerText = "Points"; | |
122 headerRow.AppendChild(points); | |
123 | |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
124 return table; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
125 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
126 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
127 private XmlElement CreateUnitRow(Unit unit, XmlDocument doc) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
128 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
129 XmlElement row = doc.CreateElement("tr"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
130 XmlElement name = doc.CreateElement("td"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
131 name.InnerText = unit.Name; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
132 row.AppendChild(name); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
133 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
134 foreach (Stat stat in unit.UnitStatsArray) |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
135 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
136 XmlElement statCell = doc.CreateElement("td"); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
137 statCell.InnerText = stat.SlotValueString; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
138 row.AppendChild(statCell); |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
139 } |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
140 |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
141 StringBuilder sb = new StringBuilder(); |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
142 bool addSeparator = false; |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
143 |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
144 foreach (UnitEquipmentItem equip in unit.GetEquipment()) |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
145 { |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
146 if (!addSeparator) |
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 addSeparator = true; |
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 else |
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 sb.Append(", "); |
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 |
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
155 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
|
156 } |
132 | 157 |
158 XmlElement notes = doc.CreateElement("td"); | |
134
57f7b80757ea
Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents:
132
diff
changeset
|
159 notes.InnerText = sb.ToString(); |
132 | 160 row.AppendChild(notes); |
161 | |
162 XmlElement points = doc.CreateElement("td"); | |
143
7f13ffcb8765
Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents:
134
diff
changeset
|
163 points.InnerText = unit.Points.ToString(); |
132 | 164 row.AppendChild(points); |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
165 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
130
diff
changeset
|
166 return row; |
130
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 } |
e147a1e9399b
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 } |