-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaWriter.cs
More file actions
64 lines (55 loc) · 1.87 KB
/
LuaWriter.cs
File metadata and controls
64 lines (55 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
namespace XmlToLuaTableConverter
{
public static class LuaWriter
{
private static string Tab = "\t";
private static string DoubleTab = "\t\t";
private static string NewLine = "\n";
public static string writeDkpTableStartEntry()
{
return "MonDKP_DKPTable = {" + NewLine;
}
public static string writeDkpTableEndEntry()
{
return "}" + NewLine;
}
public static string writeStartEntry()
{
return Tab + "{" + NewLine;
}
public static string writeEndEntry(int count)
{
return Tab + "}," + " --[" + count.ToString() + "]" + NewLine;
}
public static string writeTextAttribute(string name, string value)
{
return DoubleTab + addBracket(attributeConvert(name)) + " = " + addApostrophe(value) + "," + NewLine;
}
public static string writeDecimalAttribute(string name, decimal value)
{
return DoubleTab + addBracket(attributeConvert(name)) + " = " + value.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) + "," + NewLine;
}
private static string attributeConvert(string attributeName)
{
string convertedAttributeName = attributeName;
if(attributeName == "LifetimeGained")
{
convertedAttributeName = "lifetime_gained";
}
if (attributeName == "LifetimeSpent")
{
convertedAttributeName = "lifetime_spent";
}
return convertedAttributeName.ToLower();
}
private static string addApostrophe (string value)
{
return "\"" + value + "\"";
}
private static string addBracket(string value)
{
return "[\"" + value + "\"]";
}
}
}