Elin Decompiled Documentation EA 23.356.1 Nightly
Loading...
Searching...
No Matches
ModPackage Class Reference
Inheritance diagram for ModPackage:

Classes

struct  SheetIndex
 

Public Member Functions

void CopyContentTo (string dir)
 
IReadOnlyList< FileInfo > ParseTalkText (DirectoryInfo dir)
 
IReadOnlyList< FileInfo > ParseMap (DirectoryInfo dir, bool addToList=true)
 
IReadOnlyList< FileInfo > ParseMapPiece (DirectoryInfo dir, bool addToList=true)
 
IReadOnlyList< FileInfo > ParseTextureReplace (DirectoryInfo dir)
 
IReadOnlyList< FileInfo > ParseTexture (DirectoryInfo dir)
 
IReadOnlyList< FileInfo > ParsePortrait (DirectoryInfo dir)
 
void ParseLangMod (DirectoryInfo dir)
 
IReadOnlyList< FileInfo > ParseSound (DirectoryInfo dir)
 
override void GenerateCustomContentProfiles ()
 
override SortedDictionary< string, string > ExportSourceLocalizations ()
 
override void ImportSourceLocalizations (IReadOnlyDictionary< string, string > texts)
 
override void ClearSourceLocalizations (string lang)
 
override string UpdateSourceLocalizationFile (string lang, bool force=false)
 
void AddOrUpdateLang (DirectoryInfo dir)
 
void UpdateDialogs (DirectoryInfo dir, string dirTemp)
 
void UpdateTalks (DirectoryInfo dir, string dirTemp)
 
void UpdateExcelBook (FileInfo f, string dirTemp, bool updateOnlyText)
 
int UpdateExcelSheet (ISheet destSheet, ISheet oldSheet, bool updateOnlytext)
 

Public Attributes

Action< UINote > onBuildConfig
 
Action onResetConfig
 
string configPath
 

Detailed Description

Definition at line 10 of file ModPackage.cs.

Member Function Documentation

◆ AddOrUpdateLang()

void ModPackage.AddOrUpdateLang ( DirectoryInfo  dir)
inline

Definition at line 376 of file ModPackage.cs.

377 {
378 Core core = EClass.core;
379 SourceManager sources = core.sources;
380 DirectoryInfo[] directories = dir.GetDirectories();
381 foreach (DirectoryInfo directoryInfo in directories)
382 {
383 if (!directoryInfo.Name.StartsWith("_") && !TryAddLang(directoryInfo, isNew: false))
384 {
385 Debug.Log("Generating Language Mod Contents:" + directoryInfo.FullName);
386 IO.CopyDir(CorePath.packageCore + "Lang/EN", directoryInfo.FullName);
387 Directory.CreateDirectory(directoryInfo.FullName + "/Dialog");
388 IO.CopyDir(CorePath.packageCore + "Lang/_Dialog", directoryInfo.FullName + "/Dialog");
389 sources.ExportSourceTexts(directoryInfo.FullName + "/Game");
390 IO.Copy(CorePath.packageCore + "Lang/lang.ini", directoryInfo.FullName + "/");
391 TryAddLang(directoryInfo, isNew: true);
392 }
393 }
394 bool TryAddLang(DirectoryInfo dirLang, bool isNew)
395 {
396 string name = dirLang.Name;
397 FileInfo[] files = dirLang.GetFiles();
398 foreach (FileInfo fileInfo in files)
399 {
400 if (fileInfo.Name == "lang.ini")
401 {
402 LangSetting langSetting = new LangSetting(fileInfo.FullName)
403 {
404 id = name,
405 dir = dirLang.FullName + "/"
406 };
407 if (isNew)
408 {
409 langSetting.SetVersion();
410 }
411 else if ((Application.isEditor || Lang.runUpdate) && !Lang.IsBuiltin(dirLang.Name) && langSetting.GetVersion() < core.version.GetInt())
412 {
413 sources.Init();
414 Log.system = "Updated Language Files:" + Environment.NewLine + Environment.NewLine;
415 Debug.Log("Updating Language:" + langSetting.name + "/" + langSetting.GetVersion() + "/" + core.version.GetInt());
416 string text = dirLang.FullName + "/Game";
417 Directory.Move(text, text + "_temp");
418 sources.ExportSourceTexts(text);
419 sources.UpdateSourceTexts(text);
420 IO.DeleteDirectory(text + "_temp");
421 text = dirLang.FullName + "/Dialog";
422 Directory.Move(text, text + "_temp");
423 IO.CopyDir(CorePath.packageCore + "Lang/_Dialog", text);
424 UpdateDialogs(new DirectoryInfo(text), text + "_temp");
425 IO.DeleteDirectory(text + "_temp");
426 text = dirLang.FullName + "/Data";
427 IO.CopyDir(text, text + "_temp");
428 IO.Copy(CorePath.packageCore + "Lang/EN/Data/god_talk.xlsx", text);
429 IO.Copy(CorePath.packageCore + "Lang/EN/Data/chara_talk.xlsx", text);
430 UpdateTalks(new DirectoryInfo(text), text + "_temp");
431 IO.DeleteDirectory(text + "_temp");
432 langSetting.SetVersion();
433 IO.SaveText(dirLang.FullName + "/update.txt", Log.system);
434 }
435 MOD.langs[name] = langSetting;
436 return true;
437 }
438 }
439 return false;
440 }
441 }
Version version
Definition: BaseCore.cs:17
static string packageCore
Definition: CorePath.cs:153
Definition: Core.cs:14
SourceManager sources
Definition: Core.cs:33
Definition: EClass.cs:6
static Core core
Definition: EClass.cs:7
Definition: IO.cs:10
static void DeleteDirectory(string path)
Definition: IO.cs:392
static void Copy(string fromPath, string toPath)
Definition: IO.cs:309
static void SaveText(string path, string text)
Definition: IO.cs:103
static void CopyDir(string sourceDirectory, string targetDirectory, Func< string, bool > funcExclude=null)
Definition: IO.cs:276
string name
Definition: LangSetting.cs:24
void SetVersion()
Definition: LangSetting.cs:114
int GetVersion()
Definition: LangSetting.cs:100
Definition: Lang.cs:7
static bool IsBuiltin(string id)
Definition: Lang.cs:61
static bool runUpdate
Definition: Lang.cs:25
Definition: Log.cs:4
static string system
Definition: Log.cs:5
Definition: MOD.cs:7
static Dictionary< string, LangSetting > langs
Definition: MOD.cs:8
void UpdateDialogs(DirectoryInfo dir, string dirTemp)
Definition: ModPackage.cs:443
void UpdateTalks(DirectoryInfo dir, string dirTemp)
Definition: ModPackage.cs:460
void UpdateSourceTexts(string path)
void ExportSourceTexts(string path)
int GetInt()
Definition: Version.cs:39

References EClass.core, Debug, LangSetting.GetVersion(), Lang.IsBuiltin(), MOD.langs, LangSetting.name, CorePath.packageCore, Lang.runUpdate, LangSetting.SetVersion(), Core.sources, Log.system, UpdateDialogs(), and UpdateTalks().

Referenced by ModManager.ParseExtra().

◆ ClearSourceLocalizations()

override void ModPackage.ClearSourceLocalizations ( string  lang)
inline

Definition at line 338 of file ModPackage.cs.

339 {
340 Mapping.RebuildLangModMapping(lang);
341 for (FileInfo fileInfo = Mapping.RelocateFile("SourceLocalization.json"); fileInfo != null; fileInfo = Mapping.RelocateFile("SourceLocalization.json"))
342 {
343 fileInfo.Delete();
344 Debug.Log("#source-localization deleted " + fileInfo.ShortPath());
345 }
346 Mapping.RebuildLangModMapping(Lang.langCode);
347 }
static string langCode
Definition: Lang.cs:29

References Debug, and Lang.langCode.

◆ CopyContentTo()

void ModPackage.CopyContentTo ( string  dir)
inline

Definition at line 25 of file ModPackage.cs.

26 {
28 IO.CopyAll(dirInfo.FullName, dir);
29 EClass.ui.Say(dir);
30 }
static UI ui
Definition: EClass.cs:17
static void CopyAll(string fromPath, string toPath, bool overwrite=true)
Definition: IO.cs:337

References EClass.ui.

Referenced by LayerMod.SetModRow().

◆ ExportSourceLocalizations()

override SortedDictionary< string, string > ModPackage.ExportSourceLocalizations ( )
inline

Definition at line 307 of file ModPackage.cs.

308 {
309 SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
310 try
311 {
312 foreach (SourceData.BaseRow sourceRow in sourceRows)
313 {
314 foreach (KeyValuePair<string, string> item in sourceRow.ExportTexts(sourceRow.UseAlias ? "alias" : "id"))
315 {
316 item.Deconstruct(out var key, out var value);
317 string key2 = key;
318 string value2 = value;
319 sortedDictionary[key2] = value2;
320 }
321 }
322 }
323 catch (Exception arg)
324 {
325 Debug.LogError($"#source failed to export localization for {title}/{id}\n{arg}");
326 }
327 return sortedDictionary;
328 }

References $, Debug, and item.

Referenced by UpdateSourceLocalizationFile().

◆ GenerateCustomContentProfiles()

override void ModPackage.GenerateCustomContentProfiles ( )
inline

Definition at line 209 of file ModPackage.cs.

210 {
211 customContent.Clear();
212 foreach (SourceData.BaseRow sourceRow in sourceRows)
213 {
214 if (!(sourceRow is SourceChara.Row r))
215 {
216 if (!(sourceRow is SourceReligion.Row row))
217 {
218 if (!(sourceRow is SourceZone.Row r2))
219 {
220 if (!(sourceRow is SourceElement.Row r3))
221 {
222 if (!(sourceRow is SourceMaterial.Row r4))
223 {
224 if (!(sourceRow is SourceStat.Row r5))
225 {
226 if (!(sourceRow is SourceThing.Row r6))
227 {
228 if (!(sourceRow is SourceBlock.Row r7))
229 {
230 if (!(sourceRow is SourceFloor.Row r8))
231 {
232 if (!(sourceRow is SourceObj.Row r9))
233 {
234 if (!(sourceRow is SourceDeco.Row r10))
235 {
236 if (!(sourceRow is SourceCellEffect.Row r11))
237 {
238 if (!(sourceRow is SourceFaction.Row) && sourceRow is SourceQuest.Row)
239 {
240 }
241 }
242 else
243 {
244 customContent.Add(CustomCellEffectContent.CreateFromRow(r11, this));
245 }
246 }
247 else
248 {
249 customContent.Add(CustomDecoContent.CreateFromRow(r10, this));
250 }
251 }
252 else
253 {
254 customContent.Add(CustomObjContent.CreateFromRow(r9, this));
255 }
256 }
257 else
258 {
259 customContent.Add(CustomFloorContent.CreateFromRow(r8, this));
260 }
261 }
262 else
263 {
264 customContent.Add(CustomBlockContent.CreateFromRow(r7, this));
265 }
266 }
267 else
268 {
269 ModUtil.FixDefaultThingRowPref(r6);
270 customContent.Add(CustomThingContent.CreateFromRow(r6, this));
271 }
272 }
273 else
274 {
275 customContent.Add(CustomStatContent.CreateFromRow(r5, this));
276 }
277 }
278 else
279 {
280 customContent.Add(CustomMaterialContent.CreateFromRow(r4, this));
281 }
282 }
283 else
284 {
285 customContent.Add(CustomElementContent.CreateFromRow(r3, this));
286 }
287 }
288 else
289 {
290 customContent.Add(CustomZoneContent.CreateFromRow(r2, this));
291 }
292 }
293 else if (row.id.StartsWith("cwl") || row.id.StartsWith("custom"))
294 {
295 customContent.Add(CustomReligionContent.CreateFromRow(row, this));
296 }
297 }
298 else
299 {
300 ModUtil.FixDefaultCharaRowPref(r);
301 customContent.Add(CustomCharaContent.CreateFromRow(r, this));
302 }
303 }
304 customContent.RemoveAll((ICustomContent p) => p == null);
305 }
static CustomBlockContent CreateFromRow(SourceBlock.Row r, ModPackage owner=null)
static CustomCellEffectContent CreateFromRow(SourceCellEffect.Row r, ModPackage owner=null)
static CustomCharaContent CreateFromRow(SourceChara.Row r, ModPackage owner=null)
static CustomDecoContent CreateFromRow(SourceDeco.Row r, ModPackage owner=null)
static CustomElementContent CreateFromRow(SourceElement.Row r, ModPackage owner=null)
static CustomFloorContent CreateFromRow(SourceFloor.Row r, ModPackage owner=null)
static CustomMaterialContent CreateFromRow(SourceMaterial.Row r, ModPackage owner=null)
static CustomObjContent CreateFromRow(SourceObj.Row r, ModPackage owner=null)
static CustomStatContent CreateFromRow(SourceStat.Row r, ModPackage owner=null)
static CustomThingContent CreateFromRow(SourceThing.Row r, ModPackage mod=null)
static CustomZoneContent CreateFromRow(SourceZone.Row r, ModPackage owner=null)

References CustomBlockContent.CreateFromRow(), CustomCellEffectContent.CreateFromRow(), CustomCharaContent.CreateFromRow(), CustomDecoContent.CreateFromRow(), CustomElementContent.CreateFromRow(), CustomFloorContent.CreateFromRow(), CustomMaterialContent.CreateFromRow(), CustomObjContent.CreateFromRow(), CustomStatContent.CreateFromRow(), CustomThingContent.CreateFromRow(), and CustomZoneContent.CreateFromRow().

◆ ImportSourceLocalizations()

override void ModPackage.ImportSourceLocalizations ( IReadOnlyDictionary< string, string >  texts)
inline

Definition at line 330 of file ModPackage.cs.

331 {
332 foreach (SourceData.BaseRow sourceRow in sourceRows)
333 {
334 sourceRow.ImportTexts(texts, sourceRow.UseAlias ? "alias" : "id");
335 }
336 }

◆ ParseLangMod()

void ModPackage.ParseLangMod ( DirectoryInfo  dir)
inline

Definition at line 167 of file ModPackage.cs.

168 {
169 if (Mapping == null)
170 {
171 Mapping = new FileMapping(dir.Parent);
172 }
173 Mapping.RebuildLangModMapping(EClass.core.config?.lang ?? EClass.core.debug.langCode.ToString());
174 Lang.excelDialog = null;
175 Debug.Log("LangMod: " + string.Join(", ", Mapping.OrderedLangMods));
176 if (Mapping.SourceSheets.Count > 0)
177 {
178 Debug.Log($"Source Sheets: {Mapping.SourceSheets.Count}, {Mapping.SourceLangMod}");
179 }
180 }
string lang
Definition: CoreConfig.cs:605
Lang.LangCode langCode
Definition: CoreDebug.cs:130
CoreDebug debug
Definition: Core.cs:31
CoreConfig config
Definition: Core.cs:70

References $, Core.config, EClass.core, Core.debug, Debug, CoreConfig.lang, and CoreDebug.langCode.

Referenced by ModManager.ParseExtra().

◆ ParseMap()

IReadOnlyList< FileInfo > ModPackage.ParseMap ( DirectoryInfo  dir,
bool  addToList = true 
)
inline

Definition at line 50 of file ModPackage.cs.

51 {
52 List<FileInfo> list = new List<FileInfo>();
53 FileInfo[] files = dir.GetFiles("*.z", SearchOption.TopDirectoryOnly);
54 foreach (FileInfo fileInfo in files)
55 {
56 string key = Path.ChangeExtension(fileInfo.Name, null);
57 if (addToList)
58 {
59 MOD.listMaps.Add(fileInfo);
60 }
61 maps[key] = fileInfo;
62 list.Add(fileInfo);
63 }
64 if (list.Count > 0)
65 {
66 Debug.Log($"Map: {maps.Count}");
67 }
68 return list;
69 }
static List< FileInfo > listMaps
Definition: MOD.cs:26

References $, Debug, and MOD.listMaps.

Referenced by ModManager.ParseExtra().

◆ ParseMapPiece()

IReadOnlyList< FileInfo > ModPackage.ParseMapPiece ( DirectoryInfo  dir,
bool  addToList = true 
)
inline

Definition at line 71 of file ModPackage.cs.

72 {
73 List<FileInfo> list = new List<FileInfo>();
74 FileInfo[] files = dir.GetFiles("*.mp", SearchOption.TopDirectoryOnly);
75 foreach (FileInfo fileInfo in files)
76 {
77 string key = Path.ChangeExtension(fileInfo.Name, null);
78 if (addToList)
79 {
80 MOD.listPartialMaps.Add(fileInfo);
81 }
82 partialMaps[key] = fileInfo;
83 list.Add(fileInfo);
84 }
85 if (list.Count > 0)
86 {
87 Debug.Log($"PartialMap: {partialMaps.Count}");
88 }
89 return list;
90 }
static List< FileInfo > listPartialMaps
Definition: MOD.cs:28

References $, Debug, and MOD.listPartialMaps.

Referenced by ModManager.ParseExtra().

◆ ParsePortrait()

IReadOnlyList< FileInfo > ModPackage.ParsePortrait ( DirectoryInfo  dir)
inline

Definition at line 129 of file ModPackage.cs.

130 {
131 List<FileInfo> list = new List<FileInfo>();
132 FileInfo[] files = dir.GetFiles("*.png", SearchOption.TopDirectoryOnly);
133 foreach (FileInfo fileInfo in files)
134 {
135 string name = fileInfo.Name;
136 if (name.StartsWith("BG_", StringComparison.Ordinal))
137 {
138 Portrait.modPortraitBGs.Add(fileInfo);
139 }
140 else if (name.StartsWith("BGF_", StringComparison.Ordinal))
141 {
142 Portrait.modPortraitBGFs.Add(fileInfo);
143 }
144 else if (name.EndsWith("-full.png", StringComparison.Ordinal))
145 {
146 Portrait.modFull.Add(fileInfo);
147 }
148 else if (name.EndsWith("-overlay.png", StringComparison.Ordinal))
149 {
150 Portrait.modOverlays.Add(fileInfo);
151 }
152 else
153 {
154 Portrait.modPortraits.Add(fileInfo);
155 }
156 Portrait.allIds.Add(name);
157 portraits[name] = fileInfo;
158 list.Add(fileInfo);
159 }
160 if (list.Count > 0)
161 {
162 Debug.Log($"Portrait: {portraits.Count}");
163 }
164 return list;
165 }
void Add(FileInfo fi, string path=null, string prefix="")
Definition: ModItemList.cs:93
static ModItemList< Sprite > modPortraitBGFs
Definition: Portrait.cs:22
static ModItemList< Sprite > modPortraitBGs
Definition: Portrait.cs:24
static ModItemList< Sprite > modOverlays
Definition: Portrait.cs:28
static ModItemList< Sprite > modPortraits
Definition: Portrait.cs:26
static HashSet< string > allIds
Definition: Portrait.cs:34
static ModItemList< Sprite > modFull
Definition: Portrait.cs:30

References $, ModItemList< T >.Add(), Portrait.allIds, Debug, Portrait.modFull, Portrait.modOverlays, Portrait.modPortraitBGFs, Portrait.modPortraitBGs, and Portrait.modPortraits.

Referenced by ModManager.ParseExtra().

◆ ParseSound()

IReadOnlyList< FileInfo > ModPackage.ParseSound ( DirectoryInfo  dir)
inline

Definition at line 182 of file ModPackage.cs.

183 {
184 List<FileInfo> list = new List<FileInfo>();
185 FileInfo[] files = dir.GetFiles("*.*", SearchOption.AllDirectories);
186 foreach (FileInfo fileInfo in files)
187 {
188 if (ModUtil.GetAudioType(fileInfo.Extension) != AudioType.UNKNOWN)
189 {
190 string key = Path.ChangeExtension(Path.GetRelativePath(dir.FullName, fileInfo.FullName).NormalizePath(), null);
191 Dictionary<string, FileInfo> dictionary = MOD.sounds;
192 FileInfo value = (sounds[key] = fileInfo);
193 dictionary[key] = value;
194 list.Add(fileInfo);
195 }
196 }
197 if (list.Count > 0)
198 {
199 Debug.Log($"Sound: {sounds.Count}");
200 }
201 int num = sounds.Keys.Count((string k) => k.StartsWith("BGM/"));
202 if (num > 0)
203 {
204 Debug.Log($"BGM: {num}");
205 }
206 return list;
207 }
static Dictionary< string, FileInfo > sounds
Definition: MOD.cs:30

References $, Debug, and MOD.sounds.

Referenced by ModManager.ParseExtra().

◆ ParseTalkText()

IReadOnlyList< FileInfo > ModPackage.ParseTalkText ( DirectoryInfo  dir)
inline

Definition at line 32 of file ModPackage.cs.

33 {
34 List<FileInfo> list = new List<FileInfo>();
35 FileInfo[] files = dir.GetFiles("*.xlsx", SearchOption.TopDirectoryOnly);
36 foreach (FileInfo fileInfo in files)
37 {
38 ExcelData excelData = new ExcelData(fileInfo.FullName);
39 TalkText.modList.Add(excelData);
40 talkTexts.Add(excelData);
41 list.Add(fileInfo);
42 }
43 if (list.Count > 0)
44 {
45 Debug.Log($"TalkText: {talkTexts.Count}");
46 }
47 return list;
48 }
static List< ExcelData > modList
Definition: TalkText.cs:5

References $, Debug, and TalkText.modList.

Referenced by ModManager.ParseExtra().

◆ ParseTexture()

IReadOnlyList< FileInfo > ModPackage.ParseTexture ( DirectoryInfo  dir)
inline

Definition at line 109 of file ModPackage.cs.

110 {
111 List<FileInfo> list = new List<FileInfo>();
112 FileInfo[] files = dir.GetFiles("*.png", SearchOption.AllDirectories);
113 foreach (FileInfo fileInfo in files)
114 {
115 string key = Path.ChangeExtension(Path.GetRelativePath(dir.FullName, fileInfo.FullName).NormalizePath(), null);
116 string text = Path.ChangeExtension(fileInfo.FullName, null);
117 Dictionary<string, string> dictModItems = SpriteReplacer.dictModItems;
118 string value = (textures[key] = text);
119 dictModItems[key] = value;
120 list.Add(fileInfo);
121 }
122 if (list.Count > 0)
123 {
124 Debug.Log($"Texture: {textures.Count}");
125 }
126 return list;
127 }
static Dictionary< string, string > dictModItems

References $, Debug, and SpriteReplacer.dictModItems.

Referenced by ModManager.ParseExtra().

◆ ParseTextureReplace()

IReadOnlyList< FileInfo > ModPackage.ParseTextureReplace ( DirectoryInfo  dir)
inline

Definition at line 92 of file ModPackage.cs.

93 {
94 List<FileInfo> list = new List<FileInfo>();
95 FileInfo[] files = dir.GetFiles("*.png", SearchOption.TopDirectoryOnly);
96 foreach (FileInfo fileInfo in files)
97 {
98 string key = Path.ChangeExtension(fileInfo.Name, null);
99 textureReplaces[key] = fileInfo;
100 list.Add(fileInfo);
101 }
102 if (list.Count > 0)
103 {
104 Debug.Log($"Texture Replace: {textureReplaces.Count}");
105 }
106 return list;
107 }

References $, and Debug.

Referenced by ModManager.ParseExtra().

◆ UpdateDialogs()

void ModPackage.UpdateDialogs ( DirectoryInfo  dir,
string  dirTemp 
)
inline

Definition at line 443 of file ModPackage.cs.

444 {
445 DirectoryInfo[] directories = dir.GetDirectories();
446 foreach (DirectoryInfo directoryInfo in directories)
447 {
448 UpdateDialogs(directoryInfo, dirTemp + "/" + directoryInfo.Name);
449 }
450 FileInfo[] files = dir.GetFiles();
451 foreach (FileInfo fileInfo in files)
452 {
453 if (fileInfo.Name.EndsWith("xlsx"))
454 {
455 UpdateExcelBook(fileInfo, dirTemp, updateOnlyText: true);
456 }
457 }
458 }
void UpdateExcelBook(FileInfo f, string dirTemp, bool updateOnlyText)
Definition: ModPackage.cs:472

References UpdateDialogs(), and UpdateExcelBook().

Referenced by AddOrUpdateLang(), and UpdateDialogs().

◆ UpdateExcelBook()

void ModPackage.UpdateExcelBook ( FileInfo  f,
string  dirTemp,
bool  updateOnlyText 
)
inline

Definition at line 472 of file ModPackage.cs.

473 {
474 string path = dirTemp + "/" + f.Name;
475 if (!File.Exists(path))
476 {
477 return;
478 }
479 XSSFWorkbook xSSFWorkbook;
480 using (FileStream @is = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
481 {
482 xSSFWorkbook = new XSSFWorkbook((Stream)@is);
483 }
484 XSSFWorkbook xSSFWorkbook2;
485 using (FileStream is2 = File.Open(f.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
486 {
487 xSSFWorkbook2 = new XSSFWorkbook((Stream)is2);
488 }
489 for (int i = 0; i < xSSFWorkbook2.NumberOfSheets; i++)
490 {
491 ISheet sheetAt = xSSFWorkbook2.GetSheetAt(i);
492 ISheet sheet = xSSFWorkbook.GetSheet(sheetAt.SheetName);
493 if (sheet == null)
494 {
495 Log.system = Log.system + "Old sheet not found:" + sheetAt.SheetName + Environment.NewLine;
496 continue;
497 }
498 int num = UpdateExcelSheet(sheetAt, sheet, updateOnlyText);
499 Log.system = Log.system + ((num == 0) ? "(No Changes) " : "(Updated) ") + f.FullName + "(" + sheetAt.SheetName + ")" + Environment.NewLine;
500 if (num != 0)
501 {
502 Log.system = Log.system + num + Environment.NewLine;
503 }
504 Log.system += Environment.NewLine;
505 }
506 using FileStream stream = new FileStream(f.FullName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
507 xSSFWorkbook2.Write(stream);
508 }
int UpdateExcelSheet(ISheet destSheet, ISheet oldSheet, bool updateOnlytext)
Definition: ModPackage.cs:510

References UpdateExcelSheet().

Referenced by UpdateDialogs(), and UpdateTalks().

◆ UpdateExcelSheet()

int ModPackage.UpdateExcelSheet ( ISheet  destSheet,
ISheet  oldSheet,
bool  updateOnlytext 
)
inline

Definition at line 510 of file ModPackage.cs.

511 {
512 Dictionary<string, string[]> dictionary = new Dictionary<string, string[]>();
513 int num = 0;
514 int num2 = 0;
515 int num3 = 10;
516 IRow row = destSheet.GetRow(0);
517 IRow row2 = oldSheet.GetRow(0);
518 List<SheetIndex> list = new List<SheetIndex>();
519 int cellnum = FindField(row, "id");
520 int cellnum2 = FindField(row2, "id");
521 for (int i = 0; i < row.LastCellNum; i++)
522 {
523 ICell cell = row.GetCell(i);
524 if (cell == null)
525 {
526 break;
527 }
528 string stringCellValue = cell.StringCellValue;
529 if (stringCellValue == "id" || (updateOnlytext && stringCellValue != "text"))
530 {
531 continue;
532 }
533 for (int j = 0; j < row2.LastCellNum; j++)
534 {
535 cell = row2.GetCell(j);
536 if (cell == null)
537 {
538 break;
539 }
540 if (cell.StringCellValue == stringCellValue)
541 {
542 list.Add(new SheetIndex
543 {
544 dest = i,
545 old = j
546 });
547 Debug.Log(destSheet.SheetName + "/" + stringCellValue + "/" + i + "/" + j);
548 break;
549 }
550 }
551 }
552 for (int k = 2; k <= oldSheet.LastRowNum; k++)
553 {
554 IRow row3 = oldSheet.GetRow(k);
555 if (row3 == null)
556 {
557 if (num2 >= num3)
558 {
559 break;
560 }
561 num2++;
562 continue;
563 }
564 num2 = 0;
565 ICell cell2 = row3.GetCell(cellnum2);
566 if (cell2 == null)
567 {
568 continue;
569 }
570 string text = ((cell2.CellType == CellType.Numeric) ? cell2.NumericCellValue.ToString() : cell2.StringCellValue);
571 if (text.IsEmpty())
572 {
573 continue;
574 }
575 string[] array = new string[list.Count];
576 for (int l = 0; l < list.Count; l++)
577 {
578 ICell cell3 = row3.GetCell(list[l].old);
579 if (cell3 != null)
580 {
581 string stringCellValue2 = cell3.StringCellValue;
582 if (!stringCellValue2.IsEmpty())
583 {
584 array[l] = stringCellValue2;
585 }
586 }
587 }
588 dictionary.Add(text, array);
589 }
590 num2 = 0;
591 for (int m = 2; m <= destSheet.LastRowNum; m++)
592 {
593 IRow row4 = destSheet.GetRow(m);
594 if (row4 == null)
595 {
596 if (num2 >= num3)
597 {
598 break;
599 }
600 num2++;
601 continue;
602 }
603 num2 = 0;
604 ICell cell4 = row4.GetCell(cellnum);
605 if (cell4 == null)
606 {
607 continue;
608 }
609 string text2 = ((cell4.CellType == CellType.Numeric) ? cell4.NumericCellValue.ToString() : cell4.StringCellValue);
610 if (text2.IsEmpty() || !dictionary.ContainsKey(text2))
611 {
612 continue;
613 }
614 string[] array2 = dictionary[text2];
615 for (int n = 0; n < list.Count; n++)
616 {
617 ICell cell5 = row4.GetCell(list[n].dest) ?? row4.CreateCell(list[n].dest, CellType.String);
618 if (cell5 != null)
619 {
620 cell5.SetCellValue(array2[n]);
621 cell5.SetCellType(CellType.String);
622 cell5.SetAsActiveCell();
623 num++;
624 }
625 }
626 }
627 return num;
628 static int FindField(IRow row5, string id)
629 {
630 for (int num4 = 0; num4 < row5.LastCellNum; num4++)
631 {
632 ICell cell6 = row5.GetCell(num4);
633 if (cell6 == null)
634 {
635 break;
636 }
637 if (cell6.StringCellValue == id)
638 {
639 return num4;
640 }
641 }
642 return -1;
643 }
644 }

References Debug.

Referenced by UpdateExcelBook().

◆ UpdateSourceLocalizationFile()

override string ModPackage.UpdateSourceLocalizationFile ( string  lang,
bool  force = false 
)
inline

Definition at line 349 of file ModPackage.cs.

350 {
351 if (!base.IsSourceLocalizable)
352 {
353 return null;
354 }
355 IReadOnlyDictionary<string, string> modEntries = SourceLocalization.GetModEntries(id, lang);
356 SortedDictionary<string, string> sortedDictionary = ExportSourceLocalizations();
357 SortedDictionary<string, string> final = new SortedDictionary<string, string>();
358 foreach (var (key, defaultValue) in sortedDictionary)
359 {
360 final[key] = modEntries.GetValueOrDefault(key, defaultValue);
361 }
362 string text3 = Path.Combine(dirInfo.FullName, "LangMod/" + lang + "/SourceLocalization.json");
363 if (force || modEntries.Count != final.Count || modEntries.Any((KeyValuePair<string, string> kv) => !final.ContainsKey(kv.Key)))
364 {
365 JsonSerializerSettings setting = new JsonSerializerSettings
366 {
367 PreserveReferencesHandling = PreserveReferencesHandling.None,
368 NullValueHandling = NullValueHandling.Ignore
369 };
370 IO.SaveFile(text3, final, compress: false, setting);
371 SourceLocalization.UpdateModEntries(id, lang, final);
372 }
373 return text3;
374 }
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
Definition: IO.cs:88
override SortedDictionary< string, string > ExportSourceLocalizations()
Definition: ModPackage.cs:307

References ExportSourceLocalizations().

Referenced by LayerMod.SetModRow().

◆ UpdateTalks()

void ModPackage.UpdateTalks ( DirectoryInfo  dir,
string  dirTemp 
)
inline

Definition at line 460 of file ModPackage.cs.

461 {
462 FileInfo[] files = dir.GetFiles();
463 foreach (FileInfo fileInfo in files)
464 {
465 if (fileInfo.Name == "god_talk.xlsx" || fileInfo.Name == "chara_talk.xlsx")
466 {
467 UpdateExcelBook(fileInfo, dirTemp, updateOnlyText: false);
468 }
469 }
470 }

References UpdateExcelBook().

Referenced by AddOrUpdateLang().

Member Data Documentation

◆ configPath

string ModPackage.configPath

Definition at line 23 of file ModPackage.cs.

Referenced by LayerModConfig.Show().

◆ onBuildConfig

Action<UINote> ModPackage.onBuildConfig

Definition at line 19 of file ModPackage.cs.

Referenced by LayerMod.SetModRow(), and LayerModConfig.Show().

◆ onResetConfig

Action ModPackage.onResetConfig

Definition at line 21 of file ModPackage.cs.

Referenced by LayerModConfig.Show().


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