annotate API/Exporters/WarFoundryXMLWithXSLExporter.cs @ 401:0cfa43fd9020 xml-basic

Basic exporter completed
author Dan.Kulinski@dank-laptop.Global.Local
date Sun, 14 Aug 2011 14:40:16 -0600
parents 9a49d34599fb
children 3a71f8af5bde
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
399
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
1 // This file (WarFoundryXmlWithXslExporter.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 Dan Kulinski
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
2 //
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
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.
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
4
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
5 using System;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
6 using System.Collections.Generic;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
7 using System.IO;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
8 using System.Text;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
9 using System.Xml;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
10 using System.Xml.Xsl;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
11 using System.Xml.XPath;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
12 using System.Xml.Schema;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
13 using IBBoard.Lang;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
14 using IBBoard.Xml;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
15 using IBBoard.WarFoundry.API.Objects;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
16 using IBBoard.WarFoundry.API.Util;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
17
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
18 namespace IBBoard.WarFoundry.API.Exporters
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
19 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
20 /// <summary>
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
21 /// Custom exporter that exports an army as an XML file with an XSLT applied
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
22 /// </summary>
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
23 public class WarFoundryXmlWithXslExporter : IWarFoundryExporter
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
24 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
25 private static WarFoundryXmlWithXslExporter exporter;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
26
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
27 // Return the default class associated with this exporter
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
28 public static WarFoundryXmlWithXslExporter GetDefault()
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
29 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
30 if (exporter == null)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
31 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
32 exporter = new WarFoundryXmlWithXslExporter();
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
33 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
34
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
35 return exporter;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
36 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
37
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
38 private WarFoundryXmlWithXslExporter()
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
39 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
40 // Hide constructor
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
41 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
42
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
43 public void ExportArmy(Army army, string path)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
44 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
45 XmlDocument armyList = new XmlDocument();
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
46
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
47 // Everything will be a child of the army element
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
48 XmlElement root = armyList.CreateElement("army");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
49
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
50 // Basic army information
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
51 XmlElement armyRace = armyList.CreateElement("race");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
52 armyRace.InnerText = army.Race.Name;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
53 root.AppendChild(armyRace);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
54
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
55 XmlElement armyName = armyList.CreateElement("name");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
56 armyName.InnerText = army.Name;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
57 root.AppendChild(armyName);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
58
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
59 XmlElement armyAvailablePoints = armyList.CreateElement("pointsAvailable");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
60 armyAvailablePoints.InnerText = army.MaxPoints.ToString();
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
61 root.AppendChild(armyAvailablePoints);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
62
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
63 XmlElement armyUsedPoints = armyList.CreateElement("pointsUsed");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
64 armyUsedPoints.InnerText = army.Points.ToString();
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
65 root.AppendChild(armyUsedPoints);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
66
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
67 // Get Categories and interate through each
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
68 foreach(ArmyCategory cat in army.Categories)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
69 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
70 if (cat.GetUnits().Length == 0)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
71 continue;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
72 XmlElement armyCategory = armyList.CreateElement("category");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
73 armyCategory.SetAttribute("type", cat.Name);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
74
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
75
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
76 // Get units and iterate through each
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
77 foreach(Unit uni in cat.GetUnits())
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
78 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
79 XmlElement armyUnit = armyList.CreateElement("unit");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
80 armyUnit.SetAttribute("name", uni.UnitType.Name);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
81
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
82 foreach (Stat[] stat in uni.UnitStatsArraysWithName)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
83 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
84 XmlElement armyStatLine = armyList.CreateElement("statLine");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
85 foreach (Stat singleStat in stat)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
86 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
87 XmlElement armyStat = armyList.CreateElement("stat");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
88 armyStat.SetAttribute("name", singleStat.ParentSlotName);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
89 armyStat.SetAttribute("value", singleStat.SlotValueString);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
90 armyStatLine.AppendChild(armyStat);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
91 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
92 armyUnit.AppendChild(armyStatLine);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
93 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
94 armyUnit.SetAttribute("points", uni.Points.ToString());
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
95 armyUnit.SetAttribute("models", uni.Size.ToString());
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
96
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
97 foreach (UnitEquipmentItem equip in uni.GetEquipment())
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
98 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
99 XmlElement armyEquipmentItem = armyList.CreateElement("equipmentItem");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
100 armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString());
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
101
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
102 // Item Name
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
103 XmlElement armyEquipmentName = armyList.CreateElement("name");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
104 armyEquipmentName.InnerText = equip.Name;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
105 armyEquipmentItem.AppendChild(armyEquipmentName);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
106
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
107 // Item description
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
108 XmlElement armyEquipmentDesc = armyList.CreateElement("desc");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
109 double amount = UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
110 string amountString = "";
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
111
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
112
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
113 // TODO Change to report number, no string needed, add as attribute to armyEquipmentItem
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
114 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
115 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
116 if (amount == 100)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
117 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
118 amountString = GetEquipmentAmountAllTranslation(uni);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
119 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
120 else
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
121 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
122 int number = UnitEquipmentUtil.GetEquipmentAmountTaken(uni, equip);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
123 amountString = GetEquipmentAmountRatioTranslation(amount, number);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
124 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
125 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
126 else
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
127 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
128 if (amount == -1)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
129 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
130 amountString = GetEquipmentAmountAllTranslation(uni);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
131 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
132 else
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
133 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
134 amountString = GetEquipmentAmountNumberTranslation((int)amount);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
135 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
136 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
137 armyEquipmentDesc.InnerText = Translation.GetTranslation("armyHtmlExportEquipAmountRatio","{0} for {1}", equip.Name, amountString);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
138 armyEquipmentItem.SetAttribute("count", amountString);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
139
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
140 armyEquipmentItem.AppendChild(armyEquipmentDesc);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
141 armyUnit.AppendChild(armyEquipmentItem);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
142 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
143
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
144 foreach (Ability abil in uni.Abilities)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
145 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
146 XmlElement armyAbilityItem = armyList.CreateElement("abilityItem");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
147
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
148 XmlElement armyAbilityName = armyList.CreateElement("name");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
149 armyAbilityName.InnerText = abil.Name;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
150 armyAbilityItem.AppendChild(armyAbilityName);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
151
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
152 XmlElement armyAbilityDesc = armyList.CreateElement("description");
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
153 armyAbilityDesc.InnerText = abil.Description;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
154 armyAbilityItem.AppendChild(armyAbilityDesc);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
155
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
156 armyUnit.AppendChild(armyAbilityItem);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
157 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
158
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
159 armyCategory.AppendChild(armyUnit);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
160 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
161 root.AppendChild(armyCategory);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
162 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
163
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
164
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
165
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
166
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
167 // Append all Categories to the XML doc
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
168
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
169 // Append tree to document
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
170 armyList.AppendChild(root);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
171
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
172 // Simple XML output settings
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
173 XmlWriterSettings xmlSettings = new XmlWriterSettings();
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
174 xmlSettings.Indent = true;
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
175 xmlSettings.IndentChars = " ";
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
176
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
177 // Write XML to file
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
178 using (XmlWriter writer = XmlWriter.Create(path, xmlSettings))
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
179 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
180 armyList.Save(writer);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
181 writer.Flush();
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
182 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
183 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
184 private string GetEquipmentAmountRatioTranslation(double amount, int number)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
185 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
186 return Translation.GetTranslation("armyHtmlExportEquipAmountPercentage", "{0}% ({1})", amount, number);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
187 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
188
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
189 private string GetEquipmentAmountNumberTranslation(int amount)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
190 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
191 return Translation.GetTranslation("armyHtmlExportEquipAmountNumber", "{0}", amount);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
192 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
193
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
194 private string GetEquipmentAmountAllTranslation(Unit unit)
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
195 {
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
196 return Translation.GetTranslation("armyHtmlExportEquipAmountAll", "all ({1})", 100, unit.Size);
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
197 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
198 }
9a49d34599fb Basic XSL output
Dan.Kulinski@dank-laptop.Global.Local
parents:
diff changeset
199 }