-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppValues.cs
More file actions
122 lines (107 loc) · 3.2 KB
/
AppValues.cs
File metadata and controls
122 lines (107 loc) · 3.2 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using System.Collections.Generic;
using System.Text;
namespace LanguageXlsxToLua
{
public static class AppValues
{
public static Dictionary<string, string> Languages = new Dictionary<string, string>()
{
["CN"] = "Chinese",
["EN"] = "English",
["TH"] = "Thai",
["VN"] = "Vietnamese",
["IN"] = "Indonesian",
};
public static int ColumnCount = Languages.Count;
public static string Xlsx = ".xlsx";
public static string Lua = ".lua";
public static string XlsxPath = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) +
@"\LanguageInput\";
public static string OutputPath = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) +
@"\LanguageOutput\";
}
public struct XlsxFileInfo
{
public string Name;
public string Path;
public string NameWOSuffix;
public string Prefix;
public string NameWOPrefix;
}
public struct Field
{
/// <summary>
/// 字段名称
/// </summary>
public string Name;
/// <summary>
/// 字段值
/// </summary>
public string Value;
}
public enum LuaFieldType
{
Single = 1,
Array = 2,
Hash = 3,
}
public class LuaFieldNode
{
public LuaFieldType FieldType;
public string Value; //当lua字段直接对应单个文本时
public SortedDictionary<int, LuaFieldNode> List; //模拟lua表中的数组结构
public Dictionary<string, LuaFieldNode> Map; //模拟lua表中的哈希结构
public void AddValue(string value)
{
this.Value = value;
FieldType = LuaFieldType.Single;
}
public void AddArrayNode(int index, LuaFieldNode node)
{
if (List == null)
List = new SortedDictionary<int, LuaFieldNode>();
List[index] = node;
FieldType = LuaFieldType.Array;
}
public void AddMapNode(string key, LuaFieldNode node)
{
if (Map == null)
Map = new Dictionary<string, LuaFieldNode>();
Map[key] = node;
FieldType = LuaFieldType.Hash;
}
public void AddTableNode(string key, LuaFieldNode node)
{
if (Int32.TryParse(key, out int index))
{
AddArrayNode(index, node);
}
else
{
AddMapNode(key, node);
}
}
public bool TryGetNode(string key, out LuaFieldNode node)
{
if (int.TryParse(key, out int index))
{
if (List == null)
{
node = null;
return false;
}
return List.TryGetValue(index, out node);
}
else
{
if (Map == null)
{
node = null;
return false;
}
return Map.TryGetValue(key, out node);
}
}
}
}