Elin Decompiled Documentation EA 23.316 Nightly
Loading...
Searching...
No Matches
SourceData< T, T2 > Class Template Reference
Inheritance diagram for SourceData< T, T2 >:

Classes

class  BaseRow
 
class  FieldInfo
 
class  FieldMap
 

Public Types

enum  AutoID { None , Auto }
 

Public Member Functions

override void Init ()
 
virtual void OnInit ()
 
virtual void SetRow (T row)
 
override void Reset ()
 
override bool ImportData (ISheet sheet, string bookname, bool overwrite=false)
 
virtual void OnAfterImportData ()
 
virtual T CreateRow ()
 
virtual T CreateRowByMapping (IReadOnlyDictionary< string, int > mapping)
 
override BaseRow[] ExportRows ()
 
override int ImportRows (IEnumerable< BaseRow > sourceRows)
 
virtual void RemoveDuplicateRows ()
 
override void BackupSource ()
 
override void RollbackSource ()
 
List< string > GetListString ()
 
SourceData< T, T2 > BuildEditorList ()
 
List< FieldInfoGetFields ()
 
virtual T GetRow (string id)
 
override void ExportTexts (string path, bool update=false)
 
override void ValidateLang ()
 
override void ImportTexts (string _nameSheet=null)
 
void BuildFlags (string rawText, Dictionary< string, bool > map)
 
virtual void Reset ()
 
virtual void InsertData (IRow row)
 
virtual void Init ()
 
virtual string[] GetList (string id)
 
virtual bool ImportData (ISheet sheet, string bookname, bool overwrite=false)
 
virtual int ImportRows (IEnumerable< BaseRow > sourceRows)
 
virtual BaseRow[] ExportRows ()
 
virtual void BackupSource ()
 
virtual void RollbackSource ()
 
virtual void BackupPref ()
 
virtual void RestorePref ()
 
virtual void ValidatePref ()
 
virtual void ExportTexts (string path, bool update=false)
 
virtual void ImportTexts (string _nameSheet=null)
 
virtual void ValidateLang ()
 
virtual IReadOnlyDictionary< string, int > GetRowMapping ()
 
virtual IReadOnlyDictionary< string, string > GetTypeMapping ()
 

Static Public Member Functions

static ICell GetCell (int x, int y)
 
static bool IsNull (ICell cell)
 
static int GetInt (int id)
 
static bool GetBool (int id)
 
static double GetDouble (int id)
 
static float GetFloat (int id)
 
static float[] GetFloatArray (int id)
 
static int[] GetIntArray (int id)
 
static string[] GetStringArray (int id)
 
static string GetString (int id)
 
static string GetStr (int id, bool useDefault=false)
 

Public Attributes

List< T > rows = new List<T>()
 
Dictionary< T2, T > map = new Dictionary<T2, T>()
 
Dictionary< string, T > alias = new Dictionary<string, T>()
 
bool initialized
 
List< string > editorListString = new List<string>()
 
AutoID autoID
 
bool isNew = true
 
string nameSheet
 
string nameBook
 

Static Public Attributes

static ISheet currentSheet
 
static string LangSuffix
 
static string dataPath
 

Properties

virtual bool AllowHotInitialization [get]
 
virtual string[] ImportFields [get]
 
virtual string sheetName [get]
 
virtual string sourcePath [get]
 
static IRow row [get, set]
 
static IRow rowDefault [get, set]
 
static IRow rowHeader [get, set]
 

Private Attributes

List< T > _backupRows = new List<T>()
 

Detailed Description

Type Constraints
T :SourceData.BaseRow 

Definition at line 11 of file SourceData.cs.

Member Enumeration Documentation

◆ AutoID

Enumerator
None 
Auto 

Definition at line 640 of file SourceData.cs.

641 {
642 None,
643 Auto
644 }

Member Function Documentation

◆ BackupPref()

virtual void SourceData< T, T2 >.BackupPref ( )
inlinevirtual

Definition at line 938 of file SourceData.cs.

939 {
940 }

◆ BackupSource() [1/2]

override void SourceData< T, T2 >.BackupSource ( )
inline

Definition at line 291 of file SourceData.cs.

292 {
294 }
List< T > _backupRows
Definition: SourceData.cs:72
List< T > rows
Definition: SourceData.cs:62

References SourceData< T, T2 >._backupRows, and SourceData< T, T2 >.rows.

◆ BackupSource() [2/2]

virtual void SourceData< T, T2 >.BackupSource ( )
inlinevirtual

Definition at line 930 of file SourceData.cs.

931 {
932 }

◆ BuildEditorList()

SourceData< T, T2 > SourceData< T, T2 >.BuildEditorList ( )
inline

Definition at line 306 of file SourceData.cs.

307 {
308 if (editorListString.Count == 0)
309 {
310 foreach (T row in rows)
311 {
312 editorListString.Add(row.GetEditorListName());
313 }
314 }
315 return this;
316 }
static IRow row
Definition: SourceData.cs:851
List< string > editorListString
Definition: SourceData.cs:75

References SourceData< T, T2 >.editorListString, SourceData< T, T2 >.row, and SourceData< T, T2 >.rows.

Referenced by SourceData< T, T2 >.GetListString().

◆ BuildFlags()

void SourceData< T, T2 >.BuildFlags ( string  rawText,
Dictionary< string, bool >  map 
)
inline

Definition at line 886 of file SourceData.cs.

887 {
888 if (!string.IsNullOrEmpty(rawText))
889 {
890 string[] array = rawText.Split(',');
891 foreach (string key in array)
892 {
893 map.Add(key, value: true);
894 }
895 }
896 }
Dictionary< T2, T > map
Definition: SourceData.cs:64

References SourceData< T, T2 >.map.

◆ CreateRow()

virtual T SourceData< T, T2 >.CreateRow ( )
inlinevirtual

Definition at line 223 of file SourceData.cs.

224 {
225 return null;
226 }

Referenced by SourceData< T, T2 >.ImportData().

◆ CreateRowByMapping()

virtual T SourceData< T, T2 >.CreateRowByMapping ( IReadOnlyDictionary< string, int >  mapping)
inlinevirtual

Definition at line 228 of file SourceData.cs.

229 {
230 return null;
231 }

Referenced by SourceData< T, T2 >.ImportData().

◆ ExportRows() [1/2]

override BaseRow[] SourceData< T, T2 >.ExportRows ( )
inline

Definition at line 233 of file SourceData.cs.

234 {
235 return rows.OfType<BaseRow>().ToArray();
236 }

References SourceData< T, T2 >.rows.

◆ ExportRows() [2/2]

virtual BaseRow[] SourceData< T, T2 >.ExportRows ( )
inlinevirtual

Definition at line 925 of file SourceData.cs.

926 {
927 return Array.Empty<BaseRow>();
928 }

◆ ExportTexts() [1/2]

override void SourceData< T, T2 >.ExportTexts ( string  path,
bool  update = false 
)
inline

Definition at line 383 of file SourceData.cs.

384 {
385 Debug.Log("Exporting:" + nameSheet + " path:" + path);
386 string text = nameSheet + ".xlsx";
387 XSSFWorkbook xSSFWorkbook = new XSSFWorkbook();
388 List<FieldInfo> fields = GetFields();
389 currentSheet = xSSFWorkbook.CreateSheet(nameSheet);
390 int num = 0;
391 int y = 0;
392 foreach (FieldInfo item in fields)
393 {
394 GetCell(num, y).SetCellValue(item.name);
395 currentSheet.SetColumnWidth(num, item.width);
396 ICellStyle cellStyle = xSSFWorkbook.CreateCellStyle();
397 cellStyle.FillForegroundColor = 44;
398 cellStyle.FillPattern = FillPattern.SolidForeground;
399 if (!item.isStatic && item.id != "version")
400 {
401 GetCell(num, y).CellStyle = cellStyle;
402 }
403 num++;
404 }
405 string cellValue = BaseCore.Instance.version.GetText() ?? "";
406 y = 2;
407 foreach (T row4 in rows)
408 {
409 foreach (FieldInfo item2 in fields)
410 {
411 if (item2.isStatic)
412 {
413 GetCell(item2.column, y).SetCellValue(item2.GetValue(row4));
414 }
415 else if (item2.id == "version")
416 {
417 GetCell(item2.column, y).SetCellValue(cellValue);
418 }
419 }
420 y++;
421 }
422 currentSheet.CreateFreezePane(0, 2);
423 currentSheet.SetAutoFilter(new CellRangeAddress(1, 1, 0, fields.Count - 1));
424 if (update)
425 {
426 Dictionary<string, int> dictionary = new Dictionary<string, int>();
427 if (!File.Exists(path + "_temp/" + text))
428 {
429 return;
430 }
431 XSSFWorkbook xSSFWorkbook2;
432 using (FileStream @is = File.Open(path + "_temp/" + text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
433 {
434 xSSFWorkbook2 = new XSSFWorkbook((Stream)@is);
435 }
436 ISheet sheetAt = xSSFWorkbook2.GetSheetAt(0);
437 IRow row = sheetAt.GetRow(0);
438 int num2 = 0;
439 foreach (FieldInfo item3 in fields)
440 {
441 if (item3.isStatic)
442 {
443 continue;
444 }
445 int num3 = -1;
446 for (int i = 0; i < row.LastCellNum; i++)
447 {
448 string stringCellValue = row.GetCell(i).StringCellValue;
449 if (stringCellValue.IsEmpty())
450 {
451 break;
452 }
453 if (stringCellValue == item3.id)
454 {
455 num3 = i;
456 break;
457 }
458 }
459 if (num3 == -1)
460 {
461 continue;
462 }
463 dictionary.Add(item3.id, 0);
464 for (y = 2; y <= sheetAt.LastRowNum; y++)
465 {
466 IRow row2 = sheetAt.GetRow(y);
467 if (row2 == null)
468 {
469 if (y > 5)
470 {
471 break;
472 }
473 continue;
474 }
475 ICell cell = row2.GetCell(0);
476 if (cell == null)
477 {
478 continue;
479 }
480 string text2 = ((cell.CellType == CellType.Numeric) ? cell.NumericCellValue.ToString() : cell.StringCellValue);
481 if (text2.IsEmpty())
482 {
483 continue;
484 }
485 for (int j = 0; j <= currentSheet.LastRowNum; j++)
486 {
487 IRow row3 = currentSheet.GetRow(j);
488 if (row3 == null)
489 {
490 if (j > 5)
491 {
492 break;
493 }
494 continue;
495 }
496 ICell cell2 = row3.GetCell(0);
497 if (cell2 == null || cell2.StringCellValue != text2)
498 {
499 continue;
500 }
501 string text3 = row2.GetCell(num3)?.StringCellValue ?? "";
502 if (text3.IsEmpty())
503 {
504 continue;
505 }
506 (row3.GetCell(item3.column) ?? row3.CreateCell(item3.column)).SetCellValue(text3);
507 if (item3.id != "version")
508 {
509 ICell cell3 = row3.GetCell(item3.column + 2);
510 ICell cell4 = row2.GetCell(num3 + 2);
511 if (cell3 == null)
512 {
513 continue;
514 }
515 if (cell4 == null || cell3.StringCellValue != cell4.StringCellValue)
516 {
517 row3.GetCell(1).SetCellValue(cellValue);
518 }
519 num2++;
520 }
521 dictionary[item3.id]++;
522 }
523 }
524 }
525 Log.system = Log.system + ((num2 == 0) ? "(No Changes) " : "(Updated) ") + path + "/" + text + Environment.NewLine;
526 if (num2 != 0)
527 {
528 foreach (KeyValuePair<string, int> item4 in dictionary)
529 {
530 Log.system = Log.system + item4.Key + ":" + item4.Value + " ";
531 }
532 Log.system += Environment.NewLine;
533 }
534 Log.system += Environment.NewLine;
535 }
536 if (!Directory.Exists(path))
537 {
538 Directory.CreateDirectory(path);
539 }
540 using FileStream stream = new FileStream(path + "/" + text, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
541 xSSFWorkbook.Write(stream);
542 }
Version version
Definition: BaseCore.cs:17
static BaseCore Instance
Definition: BaseCore.cs:11
static ICell GetCell(int x, int y)
Definition: SourceData.cs:632
static ISheet currentSheet
Definition: SourceData.cs:77
string nameSheet
Definition: SourceData.cs:842
List< FieldInfo > GetFields()
Definition: SourceData.cs:318
string GetText()
Definition: Version.cs:16

References SourceData< T, T2 >.FieldInfo.column, SourceData< T, T2 >.currentSheet, Debug, SourceData< T, T2 >.GetCell(), SourceData< T, T2 >.GetFields(), Version.GetText(), SourceData< T, T2 >.FieldInfo.GetValue(), SourceData< T, T2 >.FieldInfo.id, BaseCore.Instance, SourceData< T, T2 >.FieldInfo.isStatic, item, SourceData< T, T2 >.nameSheet, SourceData< T, T2 >.row, SourceData< T, T2 >.rows, and BaseCore.version.

◆ ExportTexts() [2/2]

virtual void SourceData< T, T2 >.ExportTexts ( string  path,
bool  update = false 
)
inlinevirtual

Definition at line 950 of file SourceData.cs.

951 {
952 }

◆ GetBool()

◆ GetCell()

static ICell SourceData< T, T2 >.GetCell ( int  x,
int  y 
)
inlinestatic

Definition at line 632 of file SourceData.cs.

633 {
634 IRow row = currentSheet.GetRow(y) ?? currentSheet.CreateRow(y);
635 return row.GetCell(x) ?? row.CreateCell(x);
636 }

References SourceData< T, T2 >.currentSheet, and SourceData< T, T2 >.row.

Referenced by SourceData< T, T2 >.ExportTexts().

◆ GetDouble()

static double SourceData< T, T2 >.GetDouble ( int  id)
inlinestatic

Definition at line 991 of file SourceData.cs.

992 {
993 return ExcelParser.GetDouble(id);
994 }
static double GetDouble(int id)
Definition: ExcelParser.cs:72

References ExcelParser.GetDouble().

◆ GetFields()

List< FieldInfo > SourceData< T, T2 >.GetFields ( )
inline

Definition at line 318 of file SourceData.cs.

319 {
320 List<FieldInfo> list = new List<FieldInfo>();
321 int x = 0;
322 AddField("id", 4096);
323 AddField("version", 4096);
324 AddField("filter", 4096);
325 AddField("name", 4096);
326 AddField("text", 4096);
327 AddField("detail", 4096);
328 AddField("description", 4096);
329 string[] importFields = ImportFields;
330 foreach (string text in importFields)
331 {
332 if (!text.IsEmpty())
333 {
334 AddField(text, 4096);
335 }
336 }
337 return list;
338 void AddField(string id, int width)
339 {
340 bool flag = id == "id" || id == "filter";
341 bool flag2 = id == "version";
342 if (!(typeof(T).GetField(id) == null) || flag2)
343 {
344 list.Add(new FieldInfo
345 {
346 id = id,
347 name = id,
348 isStatic = flag,
349 width = width,
350 column = x
351 });
352 x++;
353 if (!(flag || flag2))
354 {
355 list.Add(new FieldInfo
356 {
357 id = id,
358 name = id + "_EN",
359 isStatic = true,
360 width = width,
361 column = x
362 });
363 x++;
364 list.Add(new FieldInfo
365 {
366 id = id + "_JP",
367 name = id + "_JP",
368 isStatic = true,
369 width = width,
370 column = x
371 });
372 x++;
373 }
374 }
375 }
376 }
virtual string[] ImportFields
Definition: SourceData.cs:81

References SourceData< T, T2 >.ImportFields.

Referenced by SourceData< T, T2 >.ExportTexts(), and SourceData< T, T2 >.ImportTexts().

◆ GetFloat()

◆ GetFloatArray()

static float[] SourceData< T, T2 >.GetFloatArray ( int  id)
inlinestatic

Definition at line 1001 of file SourceData.cs.

1002 {
1003 return ExcelParser.GetFloatArray(id);
1004 }
static float[] GetFloatArray(int id)
Definition: ExcelParser.cs:100

References ExcelParser.GetFloatArray().

◆ GetInt()

static int SourceData< T, T2 >.GetInt ( int  id)
inlinestatic

Definition at line 981 of file SourceData.cs.

982 {
983 return ExcelParser.GetInt(id);
984 }
static int GetInt(int id)
Definition: ExcelParser.cs:29

References ExcelParser.GetInt().

Referenced by LangWord.CreateRow(), SourceBacker.CreateRow(), SourceBlock.CreateRow(), SourceCategory.CreateRow(), SourceCellEffect.CreateRow(), SourceChara.CreateRow(), SourceCheck.CreateRow(), SourceCollectible.CreateRow(), SourceDeco.CreateRow(), SourceElement.CreateRow(), SourceFaction.CreateRow(), SourceFloor.CreateRow(), SourceFood.CreateRow(), SourceGlobalTile.CreateRow(), SourceHobby.CreateRow(), SourceHomeResource.CreateRow(), SourceJob.CreateRow(), SourceKeyItem.CreateRow(), SourceMaterial.CreateRow(), SourceObj.CreateRow(), SourcePerson.CreateRow(), SourceQuest.CreateRow(), SourceRace.CreateRow(), SourceRecipe.CreateRow(), SourceReligion.CreateRow(), SourceResearch.CreateRow(), SourceStat.CreateRow(), SourceTactics.CreateRow(), SourceThing.CreateRow(), SourceThingV.CreateRow(), SourceZone.CreateRow(), SourceZoneAffix.CreateRow(), LangWord.CreateRowByMapping(), SourceBacker.CreateRowByMapping(), SourceBlock.CreateRowByMapping(), SourceCategory.CreateRowByMapping(), SourceCellEffect.CreateRowByMapping(), SourceChara.CreateRowByMapping(), SourceCheck.CreateRowByMapping(), SourceCollectible.CreateRowByMapping(), SourceDeco.CreateRowByMapping(), SourceElement.CreateRowByMapping(), SourceFaction.CreateRowByMapping(), SourceFloor.CreateRowByMapping(), SourceFood.CreateRowByMapping(), SourceGlobalTile.CreateRowByMapping(), SourceHobby.CreateRowByMapping(), SourceHomeResource.CreateRowByMapping(), SourceJob.CreateRowByMapping(), SourceKeyItem.CreateRowByMapping(), SourceMaterial.CreateRowByMapping(), SourceObj.CreateRowByMapping(), SourcePerson.CreateRowByMapping(), SourceQuest.CreateRowByMapping(), SourceRace.CreateRowByMapping(), SourceRecipe.CreateRowByMapping(), SourceReligion.CreateRowByMapping(), SourceResearch.CreateRowByMapping(), SourceStat.CreateRowByMapping(), SourceTactics.CreateRowByMapping(), SourceThing.CreateRowByMapping(), SourceThingV.CreateRowByMapping(), SourceZone.CreateRowByMapping(), and SourceZoneAffix.CreateRowByMapping().

◆ GetIntArray()

◆ GetList()

virtual string[] SourceData< T, T2 >.GetList ( string  id)
inlinevirtual

Definition at line 910 of file SourceData.cs.

911 {
912 return null;
913 }

Referenced by Lang.GetList().

◆ GetListString()

List< string > SourceData< T, T2 >.GetListString ( )
inline

Definition at line 301 of file SourceData.cs.

302 {
303 return BuildEditorList().editorListString;
304 }
SourceData< T, T2 > BuildEditorList()
Definition: SourceData.cs:306

References SourceData< T, T2 >.BuildEditorList().

◆ GetRow()

virtual T SourceData< T, T2 >.GetRow ( string  id)
inlinevirtual

Reimplemented in SourceDataInt< T >, SourceDataString< T >, and SourceLang< T >.

Definition at line 378 of file SourceData.cs.

379 {
380 return null;
381 }

Referenced by SourceData< T, T2 >.ImportTexts().

◆ GetRowMapping()

virtual IReadOnlyDictionary< string, int > SourceData< T, T2 >.GetRowMapping ( )
inlinevirtual

Definition at line 962 of file SourceData.cs.

963 {
964 return null;
965 }

Referenced by SourceData< T, T2 >.ImportData().

◆ GetStr()

◆ GetString()

static string SourceData< T, T2 >.GetString ( int  id)
inlinestatic

Definition at line 1016 of file SourceData.cs.

1017 {
1018 return ExcelParser.GetString(id);
1019 }
static string GetString(int id)
Definition: ExcelParser.cs:160

References ExcelParser.GetString().

Referenced by LangGame.CreateRow(), LangGeneral.CreateRow(), LangList.CreateRow(), LangNote.CreateRow(), LangTalk.CreateRow(), LangWord.CreateRow(), SourceArea.CreateRow(), SourceBacker.CreateRow(), SourceBlock.CreateRow(), SourceCalc.CreateRow(), SourceCategory.CreateRow(), SourceCellEffect.CreateRow(), SourceChara.CreateRow(), SourceCharaText.CreateRow(), SourceCheck.CreateRow(), SourceCollectible.CreateRow(), SourceDeco.CreateRow(), SourceElement.CreateRow(), SourceFaction.CreateRow(), SourceFloor.CreateRow(), SourceFood.CreateRow(), SourceGlobalTile.CreateRow(), SourceHobby.CreateRow(), SourceHomeResource.CreateRow(), SourceJob.CreateRow(), SourceKeyItem.CreateRow(), SourceMaterial.CreateRow(), SourceObj.CreateRow(), SourcePerson.CreateRow(), SourceQuest.CreateRow(), SourceRace.CreateRow(), SourceRecipe.CreateRow(), SourceReligion.CreateRow(), SourceResearch.CreateRow(), SourceSpawnList.CreateRow(), SourceStat.CreateRow(), SourceTactics.CreateRow(), SourceThing.CreateRow(), SourceThingV.CreateRow(), SourceZone.CreateRow(), SourceZoneAffix.CreateRow(), LangGame.CreateRowByMapping(), LangGeneral.CreateRowByMapping(), LangList.CreateRowByMapping(), LangNote.CreateRowByMapping(), LangWord.CreateRowByMapping(), SourceArea.CreateRowByMapping(), SourceBacker.CreateRowByMapping(), SourceBlock.CreateRowByMapping(), SourceCalc.CreateRowByMapping(), SourceCategory.CreateRowByMapping(), SourceCellEffect.CreateRowByMapping(), SourceChara.CreateRowByMapping(), SourceCharaText.CreateRowByMapping(), SourceCheck.CreateRowByMapping(), SourceCollectible.CreateRowByMapping(), SourceDeco.CreateRowByMapping(), SourceElement.CreateRowByMapping(), SourceFaction.CreateRowByMapping(), SourceFloor.CreateRowByMapping(), SourceFood.CreateRowByMapping(), SourceGlobalTile.CreateRowByMapping(), SourceHobby.CreateRowByMapping(), SourceHomeResource.CreateRowByMapping(), SourceJob.CreateRowByMapping(), SourceKeyItem.CreateRowByMapping(), SourceMaterial.CreateRowByMapping(), SourceObj.CreateRowByMapping(), SourcePerson.CreateRowByMapping(), SourceQuest.CreateRowByMapping(), SourceRace.CreateRowByMapping(), SourceRecipe.CreateRowByMapping(), SourceReligion.CreateRowByMapping(), SourceResearch.CreateRowByMapping(), SourceSpawnList.CreateRowByMapping(), SourceStat.CreateRowByMapping(), SourceTactics.CreateRowByMapping(), SourceThing.CreateRowByMapping(), SourceThingV.CreateRowByMapping(), SourceZone.CreateRowByMapping(), and SourceZoneAffix.CreateRowByMapping().

◆ GetStringArray()

static string[] SourceData< T, T2 >.GetStringArray ( int  id)
inlinestatic

Definition at line 1011 of file SourceData.cs.

1012 {
1013 return ExcelParser.GetStringArray(id);
1014 }
static string[] GetStringArray(int id)
Definition: ExcelParser.cs:145

References ExcelParser.GetStringArray().

Referenced by LangList.CreateRow(), SourceBlock.CreateRow(), SourceCategory.CreateRow(), SourceCellEffect.CreateRow(), SourceChara.CreateRow(), SourceCollectible.CreateRow(), SourceDeco.CreateRow(), SourceElement.CreateRow(), SourceFloor.CreateRow(), SourceFood.CreateRow(), SourceGlobalTile.CreateRow(), SourceHobby.CreateRow(), SourceHomeResource.CreateRow(), SourceJob.CreateRow(), SourceMaterial.CreateRow(), SourceObj.CreateRow(), SourceQuest.CreateRow(), SourceRace.CreateRow(), SourceRecipe.CreateRow(), SourceReligion.CreateRow(), SourceResearch.CreateRow(), SourceSpawnList.CreateRow(), SourceStat.CreateRow(), SourceTactics.CreateRow(), SourceThing.CreateRow(), SourceThingV.CreateRow(), SourceZone.CreateRow(), LangList.CreateRowByMapping(), SourceBlock.CreateRowByMapping(), SourceCategory.CreateRowByMapping(), SourceCellEffect.CreateRowByMapping(), SourceChara.CreateRowByMapping(), SourceCollectible.CreateRowByMapping(), SourceDeco.CreateRowByMapping(), SourceElement.CreateRowByMapping(), SourceFloor.CreateRowByMapping(), SourceFood.CreateRowByMapping(), SourceGlobalTile.CreateRowByMapping(), SourceHobby.CreateRowByMapping(), SourceHomeResource.CreateRowByMapping(), SourceJob.CreateRowByMapping(), SourceMaterial.CreateRowByMapping(), SourceObj.CreateRowByMapping(), SourceQuest.CreateRowByMapping(), SourceRace.CreateRowByMapping(), SourceRecipe.CreateRowByMapping(), SourceReligion.CreateRowByMapping(), SourceResearch.CreateRowByMapping(), SourceSpawnList.CreateRowByMapping(), SourceStat.CreateRowByMapping(), SourceTactics.CreateRowByMapping(), SourceThing.CreateRowByMapping(), SourceThingV.CreateRowByMapping(), and SourceZone.CreateRowByMapping().

◆ GetTypeMapping()

virtual IReadOnlyDictionary< string, string > SourceData< T, T2 >.GetTypeMapping ( )
inlinevirtual

Definition at line 967 of file SourceData.cs.

968 {
969 return null;
970 }

◆ ImportData() [1/2]

override bool SourceData< T, T2 >.ImportData ( ISheet  sheet,
string  bookname,
bool  overwrite = false 
)
inline

Definition at line 137 of file SourceData.cs.

138 {
139 if (!overwrite)
140 {
141 rows = new List<T>();
142 }
143 isNew = true;
144 nameSheet = sheet.SheetName;
145 nameBook = bookname;
146 SourceData.rowHeader = sheet.GetRow(0);
147 SourceData.rowDefault = sheet.GetRow(2);
148 IRow row = sheet.GetRow(3);
149 if (SourceData.rowHeader == null || row == null)
150 {
151 ERROR.lastImported = 0;
152 return true;
153 }
154 IReadOnlyDictionary<string, int> rowMapping = GetRowMapping();
155 Dictionary<string, int> header = null;
156 if (rowMapping != null)
157 {
158 header = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
159 foreach (ICell cell in SourceData.rowHeader.Cells)
160 {
161 string text = cell.ToString().Trim();
162 if (!(text == "0") && !text.IsEmpty())
163 {
164 header[text] = cell.ColumnIndex;
165 }
166 }
167 if (!rowMapping.All((KeyValuePair<string, int> kv) => header.TryGetValue(kv.Key, 0) == kv.Value))
168 {
169 string[] array = rowMapping.Keys.Except(header.Keys).ToArray();
170 if (array.Length != 0)
171 {
172 Debug.LogWarning("#source ill-format file with missing columns, init with empty values\n" + ExcelParser.GetRowHeaderDiff(rowMapping, header));
173 string[] array2 = array;
174 foreach (string text2 in array2)
175 {
176 SourceData.rowHeader.CreateCell(276, CellType.String).SetCellValue(text2);
177 header[text2] = 276;
178 }
179 }
180 else
181 {
182 Debug.Log("#source ill-format file with reordered columns");
183 }
184 }
185 else
186 {
187 header = null;
188 }
189 }
190 int num = 0;
191 for (int j = 3; j <= sheet.LastRowNum; j++)
192 {
193 SourceData.row = sheet.GetRow(j);
194 try
195 {
196 if (string.IsNullOrEmpty(SourceData.row?.GetCell(0)?.ToString()))
197 {
198 break;
199 }
200 T val = ((header != null) ? CreateRowByMapping(header) : CreateRow());
201 val.OnImportData(this);
202 rows.Add(val);
203 num++;
204 continue;
205 }
206 catch (Exception arg)
207 {
208 Debug.LogError($"#source failed to create row#{j + 1}\n{arg}");
209 continue;
210 }
211 }
212 Debug.Log(sheet.SheetName + "/" + sheet.LastRowNum + "/" + num);
213 ERROR.lastImported = num;
215 initialized = false;
216 return true;
217 }
static string GetRowHeaderDiff(IReadOnlyDictionary< string, int > mapping, IReadOnlyDictionary< string, int > header)
Definition: ExcelParser.cs:239
static IRow rowHeader
Definition: SourceData.cs:875
virtual T CreateRow()
Definition: SourceData.cs:223
virtual IReadOnlyDictionary< string, int > GetRowMapping()
Definition: SourceData.cs:962
string nameBook
Definition: SourceData.cs:844
virtual void OnAfterImportData()
Definition: SourceData.cs:219
virtual T CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
Definition: SourceData.cs:228
bool initialized
Definition: SourceData.cs:69
bool isNew
Definition: SourceData.cs:840

References $, SourceData< T, T2 >.CreateRow(), SourceData< T, T2 >.CreateRowByMapping(), Debug, ExcelParser.GetRowHeaderDiff(), SourceData< T, T2 >.GetRowMapping(), SourceData< T, T2 >.initialized, SourceData< T, T2 >.isNew, SourceData< T, T2 >.nameBook, SourceData< T, T2 >.nameSheet, SourceData< T, T2 >.OnAfterImportData(), SourceData< T, T2 >.row, SourceData< T, T2 >.rowHeader, and SourceData< T, T2 >.rows.

Referenced by SourceImporter.LoadBySheetName().

◆ ImportData() [2/2]

virtual bool SourceData< T, T2 >.ImportData ( ISheet  sheet,
string  bookname,
bool  overwrite = false 
)
inlinevirtual

Definition at line 915 of file SourceData.cs.

916 {
917 return false;
918 }

◆ ImportRows() [1/2]

override int SourceData< T, T2 >.ImportRows ( IEnumerable< BaseRow sourceRows)
inline

Definition at line 238 of file SourceData.cs.

239 {
240 int num = 0;
241 foreach (BaseRow sourceRow in sourceRows)
242 {
243 if (sourceRow is T val)
244 {
245 val.OnImportData(this);
246 rows.Add(val);
247 num++;
248 }
249 }
251 initialized = false;
252 return num;
253 }

References SourceData< T, T2 >.initialized, SourceData< T, T2 >.OnAfterImportData(), and SourceData< T, T2 >.rows.

Referenced by SourceImporter.ImportFilesCached().

◆ ImportRows() [2/2]

virtual int SourceData< T, T2 >.ImportRows ( IEnumerable< BaseRow sourceRows)
inlinevirtual

Definition at line 920 of file SourceData.cs.

921 {
922 return 0;
923 }

◆ ImportTexts() [1/2]

override void SourceData< T, T2 >.ImportTexts ( string  _nameSheet = null)
inline

Definition at line 552 of file SourceData.cs.

553 {
554 string langImportMod = CorePath.CorePackage.LangImportMod;
555 string text = _nameSheet.IsEmpty(nameSheet) + ".xlsx";
556 if (!File.Exists(langImportMod + text))
557 {
558 return;
559 }
560 XSSFWorkbook xSSFWorkbook;
561 using (FileStream @is = File.Open(langImportMod + text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
562 {
563 xSSFWorkbook = new XSSFWorkbook((Stream)@is);
564 }
565 ISheet sheetAt = xSSFWorkbook.GetSheetAt(0);
566 List<FieldInfo> fields = GetFields();
567 IRow row = sheetAt.GetRow(0);
568 List<FieldMap> list = new List<FieldMap>();
569 foreach (FieldInfo item in fields)
570 {
571 if (item.isStatic)
572 {
573 continue;
574 }
575 for (int i = 0; i < row.LastCellNum; i++)
576 {
577 string stringCellValue = row.GetCell(i).StringCellValue;
578 if (stringCellValue.IsEmpty())
579 {
580 break;
581 }
582 if (stringCellValue == item.id)
583 {
584 list.Add(new FieldMap
585 {
586 field = item,
587 column = i
588 });
589 break;
590 }
591 }
592 }
593 for (int j = 2; j <= sheetAt.LastRowNum; j++)
594 {
595 IRow row2 = sheetAt.GetRow(j);
596 T val = GetRow(row2.GetCell(0).StringCellValue);
597 if (val == null)
598 {
599 Debug.Log(sheetAt.SheetName + ": id to import no longer exist: " + row2.GetCell(0).StringCellValue);
600 break;
601 }
602 foreach (FieldMap item2 in list)
603 {
604 FieldInfo field = item2.field;
605 System.Reflection.FieldInfo field2 = val.GetType().GetField(field.id + "_L");
606 if (field2 == null)
607 {
608 continue;
609 }
610 if (typeof(string[]).IsAssignableFrom(field2.FieldType))
611 {
612 ICell cell = row2.GetCell(item2.column);
613 string[] array = ((cell == null) ? new string[0] : cell.StringCellValue.Split(','));
614 string[] field3 = val.GetField<string[]>(field.id);
615 if (field3 != null)
616 {
617 field2.SetValue(val, (array.Length >= field3.Length) ? array : field3);
618 }
619 }
620 else
621 {
622 ICell cell2 = row2.GetCell(item2.column);
623 if (cell2 != null)
624 {
625 field2.SetValue(val, cell2.StringCellValue.IsEmpty(val.GetField<string>(field.id)));
626 }
627 }
628 }
629 }
630 }
static string LangImportMod
Definition: CorePath.cs:81
virtual T GetRow(string id)
Definition: SourceData.cs:378

References SourceData< T, T2 >.FieldMap.column, Debug, SourceData< T, T2 >.FieldMap.field, SourceData< T, T2 >.GetFields(), SourceData< T, T2 >.GetRow(), SourceData< T, T2 >.FieldInfo.id, item, CorePath.CorePackage.LangImportMod, SourceData< T, T2 >.nameSheet, and SourceData< T, T2 >.row.

◆ ImportTexts() [2/2]

virtual void SourceData< T, T2 >.ImportTexts ( string  _nameSheet = null)
inlinevirtual

Definition at line 954 of file SourceData.cs.

955 {
956 }

◆ Init() [1/2]

override void SourceData< T, T2 >.Init ( )
inline

Definition at line 83 of file SourceData.cs.

84 {
85 Debug.Log("Initializing:" + base.name);
86 if (initialized)
87 {
88 Debug.Log("#init Skipping sourceData.Init:" + base.name);
89 return;
90 }
91 initialized = true;
92 editorListString.Clear();
94 int num = 0;
95 foreach (T row in rows)
96 {
97 SetRow(row);
98 if (row.UseAlias)
99 {
100 alias[row.GetAlias] = row;
101 }
102 row._index = num;
103 num++;
104 }
105 OnInit();
106 }
virtual void SetRow(T row)
Definition: SourceData.cs:112
virtual void OnInit()
Definition: SourceData.cs:108
virtual void RemoveDuplicateRows()
Definition: SourceData.cs:255
Dictionary< string, T > alias
Definition: SourceData.cs:66

References SourceData< T, T2 >.alias, Debug, SourceData< T, T2 >.editorListString, SourceData< T, T2 >.initialized, SourceData< T, T2 >.OnInit(), SourceData< T, T2 >.RemoveDuplicateRows(), SourceData< T, T2 >.row, SourceData< T, T2 >.rows, and SourceData< T, T2 >.SetRow().

Referenced by SourceImporter.HotInit(), and SourceData< T, T2 >.Reset().

◆ Init() [2/2]

virtual void SourceData< T, T2 >.Init ( )
inlinevirtual

Definition at line 906 of file SourceData.cs.

907 {
908 }

◆ InsertData()

virtual void SourceData< T, T2 >.InsertData ( IRow  row)
inlinevirtual

Definition at line 902 of file SourceData.cs.

903 {
904 }

◆ IsNull()

static bool SourceData< T, T2 >.IsNull ( ICell  cell)
inlinestatic

Definition at line 972 of file SourceData.cs.

973 {
974 if (cell != null && cell.CellType != CellType.Blank)
975 {
976 return cell.CellType == CellType.Unknown;
977 }
978 return true;
979 }

◆ OnAfterImportData()

virtual void SourceData< T, T2 >.OnAfterImportData ( )
inlinevirtual

Definition at line 219 of file SourceData.cs.

220 {
221 }

Referenced by SourceData< T, T2 >.ImportData(), and SourceData< T, T2 >.ImportRows().

◆ OnInit()

virtual void SourceData< T, T2 >.OnInit ( )
inlinevirtual

Definition at line 108 of file SourceData.cs.

109 {
110 }

Referenced by SourceData< T, T2 >.Init().

◆ RemoveDuplicateRows()

virtual void SourceData< T, T2 >.RemoveDuplicateRows ( )
inlinevirtual

Definition at line 255 of file SourceData.cs.

256 {
257 HashSet<T2> hashSet = new HashSet<T2>();
258 List<T> list = new List<T>(rows.Count);
259 string arg = GetType().Name;
260 System.Reflection.FieldInfo field = typeof(T).GetField("id");
261 bool flag = typeof(LangRow).IsAssignableFrom(typeof(T));
262 if (field == null)
263 {
264 return;
265 }
266 if (field.FieldType != typeof(T2))
267 {
268 Debug.LogError($"#source-override: {arg} id field mismatch {field.FieldType} != {typeof(T2)}");
269 }
270 for (int num = rows.Count - 1; num >= 0; num--)
271 {
272 T val = rows[num];
273 T2 val2 = (T2)field.GetValue(val);
274 if (hashSet.Add(val2))
275 {
276 list.Add(val);
277 }
278 else if (!flag)
279 {
280 Debug.Log($"#source-override: {arg} {val2}");
281 }
282 }
283 if (rows.Count != list.Count)
284 {
285 Debug.Log($"#source-override: {arg} total/{rows.Count} -> unique/{list.Count}");
286 list.Reverse();
287 rows = list;
288 }
289 }

References $, Debug, and SourceData< T, T2 >.rows.

Referenced by SourceData< T, T2 >.Init().

◆ Reset() [1/2]

override void SourceData< T, T2 >.Reset ( )
inline

Definition at line 116 of file SourceData.cs.

117 {
118 initialized = false;
119 if (!Application.isPlaying)
120 {
121 BaseCore.resetRuntime = true;
122 }
123 if (map != null)
124 {
125 map.Clear();
126 }
127 if (alias != null)
128 {
129 alias.Clear();
130 }
131 if (Application.isPlaying && AllowHotInitialization)
132 {
133 Init();
134 }
135 }
override void Init()
Definition: SourceData.cs:83
virtual bool AllowHotInitialization
Definition: SourceData.cs:79

References SourceData< T, T2 >.alias, SourceData< T, T2 >.AllowHotInitialization, SourceData< T, T2 >.Init(), SourceData< T, T2 >.initialized, and SourceData< T, T2 >.map.

Referenced by SourceImporter.HotInit().

◆ Reset() [2/2]

virtual void SourceData< T, T2 >.Reset ( )
inlinevirtual

Definition at line 898 of file SourceData.cs.

899 {
900 }

◆ RestorePref()

virtual void SourceData< T, T2 >.RestorePref ( )
inlinevirtual

Definition at line 942 of file SourceData.cs.

943 {
944 }

◆ RollbackSource() [1/2]

override void SourceData< T, T2 >.RollbackSource ( )
inline

Definition at line 296 of file SourceData.cs.

297 {
299 }

References SourceData< T, T2 >._backupRows, and SourceData< T, T2 >.rows.

◆ RollbackSource() [2/2]

virtual void SourceData< T, T2 >.RollbackSource ( )
inlinevirtual

Definition at line 934 of file SourceData.cs.

935 {
936 }

◆ SetRow()

virtual void SourceData< T, T2 >.SetRow ( row)
inlinevirtual

Definition at line 112 of file SourceData.cs.

113 {
114 }

Referenced by SourceData< T, T2 >.Init().

◆ ValidateLang() [1/2]

override void SourceData< T, T2 >.ValidateLang ( )
inline

Definition at line 544 of file SourceData.cs.

545 {
546 string langImportMod = CorePath.CorePackage.LangImportMod;
547 string text = nameSheet + ".xlsx";
548 Log.system = Log.system + langImportMod + text + Environment.NewLine;
549 Log.system += Environment.NewLine;
550 }

References CorePath.CorePackage.LangImportMod, and SourceData< T, T2 >.nameSheet.

◆ ValidateLang() [2/2]

virtual void SourceData< T, T2 >.ValidateLang ( )
inlinevirtual

Definition at line 958 of file SourceData.cs.

959 {
960 }

◆ ValidatePref()

virtual void SourceData< T, T2 >.ValidatePref ( )
inlinevirtual

Definition at line 946 of file SourceData.cs.

947 {
948 }

Member Data Documentation

◆ _backupRows

List<T> SourceData< T, T2 >._backupRows = new List<T>()
private

◆ alias

Dictionary<string, T> SourceData< T, T2 >.alias = new Dictionary<string, T>()

Definition at line 66 of file SourceData.cs.

Referenced by SourceData< T, T2 >.Init(), and SourceData< T, T2 >.Reset().

◆ autoID

AutoID SourceData< T, T2 >.autoID

Definition at line 838 of file SourceData.cs.

◆ currentSheet

ISheet SourceData< T, T2 >.currentSheet
static

Definition at line 77 of file SourceData.cs.

Referenced by SourceData< T, T2 >.ExportTexts(), and SourceData< T, T2 >.GetCell().

◆ dataPath

string SourceData< T, T2 >.dataPath
static

Definition at line 836 of file SourceData.cs.

◆ editorListString

List<string> SourceData< T, T2 >.editorListString = new List<string>()

Definition at line 75 of file SourceData.cs.

Referenced by SourceData< T, T2 >.BuildEditorList(), and SourceData< T, T2 >.Init().

◆ initialized

◆ isNew

bool SourceData< T, T2 >.isNew = true

Definition at line 840 of file SourceData.cs.

Referenced by SourceData< T, T2 >.ImportData().

◆ LangSuffix

string SourceData< T, T2 >.LangSuffix
static

◆ map

Dictionary<T2, T> SourceData< T, T2 >.map = new Dictionary<T2, T>()

Definition at line 64 of file SourceData.cs.

Referenced by SourceData< T, T2 >.BuildFlags(), and SourceData< T, T2 >.Reset().

◆ nameBook

string SourceData< T, T2 >.nameBook

Definition at line 844 of file SourceData.cs.

Referenced by SourceData< T, T2 >.ImportData().

◆ nameSheet

◆ rows

Property Documentation

◆ AllowHotInitialization

virtual bool SourceData< T, T2 >.AllowHotInitialization
get

Definition at line 79 of file SourceData.cs.

Referenced by SourceData< T, T2 >.Reset().

◆ ImportFields

virtual string [] SourceData< T, T2 >.ImportFields
get

Definition at line 81 of file SourceData.cs.

Referenced by SourceData< T, T2 >.GetFields().

◆ row

IRow SourceData< T, T2 >.row
staticgetset

Definition at line 850 of file SourceData.cs.

851 {
852 get
853 {
854 return ExcelParser.row;
855 }
856 set
857 {
858 ExcelParser.row = value;
859 }
860 }
static IRow row
Definition: ExcelParser.cs:12

Referenced by SourceData< T, T2 >.BuildEditorList(), SourceData< T, T2 >.ExportTexts(), SourceData< T, T2 >.GetCell(), SourceData< T, T2 >.ImportData(), SourceData< T, T2 >.ImportTexts(), and SourceData< T, T2 >.Init().

◆ rowDefault

IRow SourceData< T, T2 >.rowDefault
staticgetset

Definition at line 862 of file SourceData.cs.

863 {
864 get
865 {
866 return ExcelParser.rowDefault;
867 }
868 set
869 {
870 ExcelParser.rowDefault = value;
871 }
872 }
static IRow rowDefault
Definition: ExcelParser.cs:14

◆ rowHeader

IRow SourceData< T, T2 >.rowHeader
staticgetset

Definition at line 874 of file SourceData.cs.

875 {
876 get
877 {
878 return ExcelParser.rowHeader;
879 }
880 set
881 {
882 ExcelParser.rowHeader = value;
883 }
884 }
static IRow rowHeader
Definition: ExcelParser.cs:16

Referenced by SourceData< T, T2 >.ImportData().

◆ sheetName

virtual string SourceData< T, T2 >.sheetName
get

Definition at line 846 of file SourceData.cs.

◆ sourcePath

virtual string SourceData< T, T2 >.sourcePath
get

Definition at line 848 of file SourceData.cs.


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