Elin Decompiled Documentation EA 23.197 Nightly Patch 1
Loading...
Searching...
No Matches
ModUtil.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using NPOI.SS.UserModel;
5using NPOI.XSSF.UserModel;
6using UnityEngine;
7
8public class ModUtil : EClass
9{
10 public static Dictionary<string, string> fallbackTypes = new Dictionary<string, string>();
11
12 public static void Test()
13 {
15 }
16
17 public static void OnModsActivated()
18 {
19 }
20
21 public static void LoadTypeFallback()
22 {
23 string text = "type_resolver.txt";
24 string[] array = new string[0];
25 if (File.Exists(CorePath.RootData + text))
26 {
27 array = IO.LoadTextArray(CorePath.RootData + text);
28 }
29 else
30 {
31 array = new string[2] { "TrueArena,ArenaWaveEvent,ZoneEvent", "Elin-GeneRecombinator,Elin_GeneRecombinator.IncubationSacrifice,Chara" };
32 IO.SaveTextArray(CorePath.RootData + text, array);
33 }
34 string[] array2 = array;
35 for (int i = 0; i < array2.Length; i++)
36 {
37 string[] array3 = array2[i].Split(',');
38 if (array3.Length >= 2)
39 {
40 RegisterSerializedTypeFallback(array3[0], array3[1], array3[2]);
41 }
42 }
43 }
44
45 public static void RegisterSerializedTypeFallback(string nameAssembly, string nameType, string nameFallbackType)
46 {
47 fallbackTypes[nameType] = nameFallbackType;
48 }
49
50 public static void ImportExcel(string pathToExcelFile, string sheetName, SourceData source)
51 {
52 Debug.Log("ImportExcel source:" + source?.ToString() + " Path:" + pathToExcelFile);
53 using FileStream @is = File.Open(pathToExcelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
54 XSSFWorkbook xSSFWorkbook = new XSSFWorkbook((Stream)@is);
55 for (int i = 0; i < xSSFWorkbook.NumberOfSheets; i++)
56 {
57 ISheet sheetAt = xSSFWorkbook.GetSheetAt(i);
58 if (sheetAt.SheetName != sheetName)
59 {
60 continue;
61 }
62 Debug.Log("Importing Sheet:" + sheetName);
63 try
64 {
65 if (!source.ImportData(sheetAt, new FileInfo(pathToExcelFile).Name, overwrite: true))
66 {
67 Debug.LogError(ERROR.msg);
68 break;
69 }
70 Debug.Log("Imported " + sheetAt.SheetName);
71 source.Reset();
72 }
73 catch (Exception ex)
74 {
75 Debug.LogError("[Error] Skipping import " + sheetAt.SheetName + " :" + ex.Message + "/" + ex.Source + "/" + ex.StackTrace);
76 break;
77 }
78 }
79 }
80}
static string RootData
Definition: CorePath.cs:204
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
Definition: ERROR.cs:2
static string msg
Definition: ERROR.cs:3
static void Test()
Definition: ModUtil.cs:12
static void RegisterSerializedTypeFallback(string nameAssembly, string nameType, string nameFallbackType)
Definition: ModUtil.cs:45
static Dictionary< string, string > fallbackTypes
Definition: ModUtil.cs:10
static void OnModsActivated()
Definition: ModUtil.cs:17
static void LoadTypeFallback()
Definition: ModUtil.cs:21
static void ImportExcel(string pathToExcelFile, string sheetName, SourceData source)
Definition: ModUtil.cs:50
override bool ImportData(ISheet sheet, string bookname, bool overwrite=false)
Definition: SourceData.cs:134
override void Reset()
Definition: SourceData.cs:113
SourceChara charas