Skip to content

Commit

Permalink
additional Fields get output in RTF;
Browse files Browse the repository at this point in the history
  • Loading branch information
eisbaer66 committed Apr 14, 2020
1 parent cb7ab2c commit 5c77926
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Tf2Rebalance.CreateSummary.Tests/ConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void Text(string inputFilename, string expectedOutputFilename)
[DataRow("tf2rebalance_attributes.example.txt", "tf2rebalance_attributes.example_summary.rtf")]
[DataRow("higps.txt", "higps_summary.rtf")]
[DataRow("higps_withoutClasses.txt", "higps_withoutClasses_summary.rtf")]
[DataRow("additionalFields.txt", "additionalFields_summary.rtf")]
public void Rtf(string inputFilename, string expectedOutputFilename)
{
string input = File.ReadAllText(inputFilename);
Expand All @@ -57,6 +58,7 @@ public void Rtf(string inputFilename, string expectedOutputFilename)
IEnumerable<RebalanceInfo> rebalanceInfos = rebalanceInfoConverter.Execute(input);
string output = formatter.Create(rebalanceInfos);

File.WriteAllText("test.rtf", output);
Assert.AreEqual(expectedOutput, output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<None Update="additionalFields_summary.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="additionalFields_summary.rtf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="higps_summary.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
42 changes: 42 additions & 0 deletions Tf2Rebalance.CreateSummary.Tests/additionalFields_summary.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{\rtf1\ansi\deff0

{\fonttbl
{\f0 Times New Roman;}
}

{\colortbl
;
}

\deflang1033\plain\fs24\widowctrl\hyphauto\ftnbj
\paperw11906\paperh16838
\margt1000
\margr1000
\margb1000
\margl1000


{\pard\fi0\ql
{\b\i\ul Weapons}
\par}

{\pard\fi0\ql
{\b\ul Scout}
\par}

{\pard\fi0\ql
{\i Melee }
\par}

{\pard\fi0\ql
{\b Sun-on-a-Stick}
\par}

{\pard\fi0\ql
{increased dmg to people on fire by 100%\line
why: because i can\line
rank: bestest\line
}
\par}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RtfWriter.Standard;
using System.Collections.Generic;
using RtfWriter.Standard;

namespace Tf2Rebalance.CreateSummary.Formatter
{
Expand Down Expand Up @@ -46,6 +47,17 @@ protected override void Write(string weaponnames, Info weapon)
RtfParagraph paragraph = _document.addParagraph();
RtfCharFormat format = paragraph.addCharFormat();
paragraph.Text.AppendLine(weapon.info);

if (weapon.additionalFields == null)
return;

foreach (KeyValuePair<string, string> pair in weapon.additionalFields)
{
paragraph.Text.Append(pair.Key);
paragraph.Text.Append(": ");
paragraph.Text.Append(pair.Value);
paragraph.Text.AppendLine();
}
}

protected override string Finalize()
Expand Down

0 comments on commit 5c77926

Please sign in to comment.