Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TextConv Class Reference
Inheritance diagram for TextConv:
ExcelData

Classes

class  Item
 

Public Member Functions

StringBuilder Apply (ref string text, int gender)
 
override void BuildMap (string sheetName=null)
 
- Public Member Functions inherited from ExcelData
 ExcelData ()
 
 ExcelData (string _path, int _index)
 
 ExcelData (string _path)
 
void LoadBook ()
 
bool IsModified ()
 
virtual void BuildMap (string sheetName="_default")
 
List< Dictionary< string, string > > BuildList (string sheetName="_default")
 
void Override (Dictionary< string, SourceData > sources, bool canAddData=true)
 
string GetText (string id, string topic="text")
 

Public Attributes

string[] I_M
 
string[] I_F
 
string[] you_M
 
string[] you_F
 
string[] tags
 
int p_I_M
 
int p_I_F
 
int p_you_M
 
int p_you_F
 
List< Itemitems = new List<Item>()
 
- Public Attributes inherited from ExcelData
int startIndex = 5
 
XSSFWorkbook book
 
IRow rowIndex
 
Dictionary< string, Sheetsheets = new Dictionary<string, Sheet>()
 
string path
 
int maxEmptyRows
 
DateTime lastModified
 

Detailed Description

Definition at line 6 of file TextConv.cs.

Member Function Documentation

◆ Apply()

StringBuilder TextConv.Apply ( ref string  text,
int  gender 
)
inline

Definition at line 71 of file TextConv.cs.

72 {
73 BuildMap(null);
74 StringBuilder stringBuilder = new StringBuilder();
75 string text2 = null;
76 Item item = null;
77 int num = 0;
78 if (gender == 0)
79 {
80 gender = ((Rand.rnd(3) != 0) ? 1 : 2);
81 }
82 while (num < text.Length)
83 {
84 bool flag = false;
85 foreach (Item item2 in items)
86 {
87 if ((item2.probab != 0 && Rand.Range(0, 100) >= item2.probab) || (item2.gender != 0 && gender != item2.gender))
88 {
89 continue;
90 }
91 string[] keys = item2.keys;
92 foreach (string text3 in keys)
93 {
94 flag = true;
95 for (int j = 0; j < text3.Length; j++)
96 {
97 if (num + j >= text.Length || text[num + j] != text3[j])
98 {
99 flag = false;
100 break;
101 }
102 }
103 if (flag && item2.suffix != null)
104 {
105 flag = false;
106 if (num + text3.Length >= text.Length)
107 {
108 continue;
109 }
110 string[] suffix = item2.suffix;
111 foreach (string text4 in suffix)
112 {
113 if (text[num + text3.Length] == text4[0])
114 {
115 flag = true;
116 break;
117 }
118 }
119 }
120 if (flag)
121 {
122 item = item2;
123 text2 = text3;
124 break;
125 }
126 }
127 if (flag)
128 {
129 break;
130 }
131 }
132 if (flag && text2.Length > 0)
133 {
134 stringBuilder.Append((item.additive ? text2 : "") + item.strs[Rand.Range(0, item.strs.Length)]);
135 num += text2.Length;
136 }
137 else
138 {
139 stringBuilder.Append(text[num]);
140 num++;
141 }
142 }
143 stringBuilder.Replace("…ー", "ー…");
144 return stringBuilder;
145 }
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:42
static int rnd(int max)
Definition: Rand.cs:52
List< Item > items
Definition: TextConv.cs:69
override void BuildMap(string sheetName=null)
Definition: TextConv.cs:147

References BuildMap(), TextConv.Item.gender, item, items, TextConv.Item.keys, TextConv.Item.probab, Rand.Range(), Rand.rnd(), and TextConv.Item.suffix.

◆ BuildMap()

override void TextConv.BuildMap ( string  sheetName = null)
inlinevirtual

Reimplemented from ExcelData.

Definition at line 147 of file TextConv.cs.

148 {
149 LoadBook();
150 ISheet sheetAt = book.GetSheetAt(0);
151 if (sheetAt.LastRowNum <= 3)
152 {
153 return;
154 }
155 for (int i = 3; i <= sheetAt.LastRowNum; i++)
156 {
157 IRow row = sheetAt.GetRow(i);
158 if (row.Cells.Count == 0)
159 {
160 Debug.LogWarning(path + "/" + book?.ToString() + "/" + sheetName + "/" + sheetAt.LastRowNum + "/" + i);
161 continue;
162 }
163 string text = row.GetCell(0).ToString();
164 if (text.IsEmpty())
165 {
166 Debug.LogWarning(path + "/" + book?.ToString() + "/" + sheetName + "/" + sheetAt.LastRowNum + "/" + i);
167 continue;
168 }
169 string text2 = row.GetCell(1).ToString();
170 string text3 = row.GetCell(2)?.ToString() ?? "";
171 int @int = ExcelParser.GetInt(4, row);
172 if (text[0] == '$')
173 {
174 switch (text + "_" + text3)
175 {
176 case "$I_":
177 I_M = (I_F = text2.Split(','));
178 p_I_M = (p_I_F = @int);
179 break;
180 case "$you_":
181 you_M = (you_F = text2.Split(','));
182 p_you_M = (p_you_F = @int);
183 break;
184 case "$I_M":
185 I_M = text2.Split(',');
186 p_I_M = @int;
187 break;
188 case "$you_M":
189 you_M = text2.Split(',');
190 p_you_M = @int;
191 break;
192 case "$I_F":
193 I_F = text2.Split(',');
194 p_I_F = @int;
195 break;
196 case "$you_F":
197 you_F = text2.Split(',');
198 p_you_F = @int;
199 break;
200 case "$tag":
201 tags = text2.Split(',');
202 break;
203 }
204 }
205 items.Add(new Item(row, text, text2, text3, @int));
206 }
207 }
void LoadBook()
Definition: ExcelData.cs:49
XSSFWorkbook book
Definition: ExcelData.cs:21
string path
Definition: ExcelData.cs:27
static int GetInt(int id)
Definition: ExcelParser.cs:19
string[] I_F
Definition: TextConv.cs:53
int p_I_F
Definition: TextConv.cs:63
int p_you_F
Definition: TextConv.cs:67
int p_you_M
Definition: TextConv.cs:65
string[] tags
Definition: TextConv.cs:59
string[] you_M
Definition: TextConv.cs:55
string[] you_F
Definition: TextConv.cs:57
int p_I_M
Definition: TextConv.cs:61
string[] I_M
Definition: TextConv.cs:51

References ExcelData.book, Debug, ExcelParser.GetInt(), I_F, I_M, items, ExcelData.LoadBook(), p_I_F, p_I_M, p_you_F, p_you_M, ExcelData.path, tags, you_F, and you_M.

Referenced by Apply().

Member Data Documentation

◆ I_F

string [] TextConv.I_F

Definition at line 53 of file TextConv.cs.

Referenced by BuildMap().

◆ I_M

string [] TextConv.I_M

Definition at line 51 of file TextConv.cs.

Referenced by BuildMap().

◆ items

List<Item> TextConv.items = new List<Item>()

Definition at line 69 of file TextConv.cs.

Referenced by Apply(), and BuildMap().

◆ p_I_F

int TextConv.p_I_F

Definition at line 63 of file TextConv.cs.

Referenced by BuildMap().

◆ p_I_M

int TextConv.p_I_M

Definition at line 61 of file TextConv.cs.

Referenced by BuildMap().

◆ p_you_F

int TextConv.p_you_F

Definition at line 67 of file TextConv.cs.

Referenced by BuildMap().

◆ p_you_M

int TextConv.p_you_M

Definition at line 65 of file TextConv.cs.

Referenced by BuildMap().

◆ tags

string [] TextConv.tags

Definition at line 59 of file TextConv.cs.

Referenced by BuildMap().

◆ you_F

string [] TextConv.you_F

Definition at line 57 of file TextConv.cs.

Referenced by BuildMap().

◆ you_M

string [] TextConv.you_M

Definition at line 55 of file TextConv.cs.

Referenced by BuildMap().


The documentation for this class was generated from the following file: