Skip to content

Commit 5c77926

Browse files
committed
additional Fields get output in RTF;
1 parent cb7ab2c commit 5c77926

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

Tf2Rebalance.CreateSummary.Tests/ConverterTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void Text(string inputFilename, string expectedOutputFilename)
4646
[DataRow("tf2rebalance_attributes.example.txt", "tf2rebalance_attributes.example_summary.rtf")]
4747
[DataRow("higps.txt", "higps_summary.rtf")]
4848
[DataRow("higps_withoutClasses.txt", "higps_withoutClasses_summary.rtf")]
49+
[DataRow("additionalFields.txt", "additionalFields_summary.rtf")]
4950
public void Rtf(string inputFilename, string expectedOutputFilename)
5051
{
5152
string input = File.ReadAllText(inputFilename);
@@ -57,6 +58,7 @@ public void Rtf(string inputFilename, string expectedOutputFilename)
5758
IEnumerable<RebalanceInfo> rebalanceInfos = rebalanceInfoConverter.Execute(input);
5859
string output = formatter.Create(rebalanceInfos);
5960

61+
File.WriteAllText("test.rtf", output);
6062
Assert.AreEqual(expectedOutput, output);
6163
}
6264

Tf2Rebalance.CreateSummary.Tests/Tf2Rebalance.CreateSummary.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<None Update="additionalFields_summary.json">
3131
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3232
</None>
33+
<None Update="additionalFields_summary.rtf">
34+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
35+
</None>
3336
<None Update="higps_summary.json">
3437
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3538
</None>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{\rtf1\ansi\deff0
2+
3+
{\fonttbl
4+
{\f0 Times New Roman;}
5+
}
6+
7+
{\colortbl
8+
;
9+
}
10+
11+
\deflang1033\plain\fs24\widowctrl\hyphauto\ftnbj
12+
\paperw11906\paperh16838
13+
\margt1000
14+
\margr1000
15+
\margb1000
16+
\margl1000
17+
18+
19+
{\pard\fi0\ql
20+
{\b\i\ul Weapons}
21+
\par}
22+
23+
{\pard\fi0\ql
24+
{\b\ul Scout}
25+
\par}
26+
27+
{\pard\fi0\ql
28+
{\i Melee }
29+
\par}
30+
31+
{\pard\fi0\ql
32+
{\b Sun-on-a-Stick}
33+
\par}
34+
35+
{\pard\fi0\ql
36+
{increased dmg to people on fire by 100%\line
37+
why: because i can\line
38+
rank: bestest\line
39+
}
40+
\par}
41+
42+
}

Tf2Rebalance.CreateSummary/Formatter/RebalanceInfoRtfFormatter.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using RtfWriter.Standard;
1+
using System.Collections.Generic;
2+
using RtfWriter.Standard;
23

34
namespace Tf2Rebalance.CreateSummary.Formatter
45
{
@@ -46,6 +47,17 @@ protected override void Write(string weaponnames, Info weapon)
4647
RtfParagraph paragraph = _document.addParagraph();
4748
RtfCharFormat format = paragraph.addCharFormat();
4849
paragraph.Text.AppendLine(weapon.info);
50+
51+
if (weapon.additionalFields == null)
52+
return;
53+
54+
foreach (KeyValuePair<string, string> pair in weapon.additionalFields)
55+
{
56+
paragraph.Text.Append(pair.Key);
57+
paragraph.Text.Append(": ");
58+
paragraph.Text.Append(pair.Value);
59+
paragraph.Text.AppendLine();
60+
}
4961
}
5062

5163
protected override string Finalize()

0 commit comments

Comments
 (0)