Elin Decompiled Documentation EA 23.344.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)
 

Detailed Description

Definition at line 10 of file ModPackage.cs.

Member Function Documentation

◆ AddOrUpdateLang()

void ModPackage.AddOrUpdateLang ( DirectoryInfo  dir)
inline

Definition at line 370 of file ModPackage.cs.

371 {
372 Core core = EClass.core;
373 SourceManager sources = core.sources;
374 DirectoryInfo[] directories = dir.GetDirectories();
375 foreach (DirectoryInfo directoryInfo in directories)
376 {
377 if (!directoryInfo.Name.StartsWith("_") && !TryAddLang(directoryInfo, isNew: false))
378 {
379 Debug.Log("Generating Language Mod Contents:" + directoryInfo.FullName);
380 IO.CopyDir(CorePath.packageCore + "Lang/EN", directoryInfo.FullName);
381 Directory.CreateDirectory(directoryInfo.FullName + "/Dialog");
382 IO.CopyDir(CorePath.packageCore + "Lang/_Dialog", directoryInfo.FullName + "/Dialog");
383 sources.ExportSourceTexts(directoryInfo.FullName + "/Game");
384 IO.Copy(CorePath.packageCore + "Lang/lang.ini", directoryInfo.FullName + "/");
385 TryAddLang(directoryInfo, isNew: true);
386 }
387 }
388 bool TryAddLang(DirectoryInfo dirLang, bool isNew)
389 {
390 string name = dirLang.Name;
391 FileInfo[] files = dirLang.GetFiles();
392 foreach (FileInfo fileInfo in files)
393 {
394 if (fileInfo.Name == "lang.ini")
395 {
396 LangSetting langSetting = new LangSetting(fileInfo.FullName)
397 {
398 id = name,
399 dir = dirLang.FullName + "/"
400 };
401 if (isNew)
402 {
403 langSetting.SetVersion();
404 }
405 else if ((Application.isEditor || Lang.runUpdate) && !Lang.IsBuiltin(dirLang.Name) && langSetting.GetVersion() < core.version.GetInt())
406 {
407 sources.Init();
408 Log.system = "Updated Language Files:" + Environment.NewLine + Environment.NewLine;
409 Debug.Log("Updating Language:" + langSetting.name + "/" + langSetting.GetVersion() + "/" + core.version.GetInt());
410 string text = dirLang.FullName + "/Game";
411 Directory.Move(text, text + "_temp");
412 sources.ExportSourceTexts(text);
413 sources.UpdateSourceTexts(text);
414 IO.DeleteDirectory(text + "_temp");
415 text = dirLang.FullName + "/Dialog";
416 Directory.Move(text, text + "_temp");
417 IO.CopyDir(CorePath.packageCore + "Lang/_Dialog", text);
418 UpdateDialogs(new DirectoryInfo(text), text + "_temp");
419 IO.DeleteDirectory(text + "_temp");
420 text = dirLang.FullName + "/Data";
421 IO.CopyDir(text, text + "_temp");
422 IO.Copy(CorePath.packageCore + "Lang/EN/Data/god_talk.xlsx", text);
423 IO.Copy(CorePath.packageCore + "Lang/EN/Data/chara_talk.xlsx", text);
424 UpdateTalks(new DirectoryInfo(text), text + "_temp");
425 IO.DeleteDirectory(text + "_temp");
426 langSetting.SetVersion();
427 IO.SaveText(dirLang.FullName + "/update.txt", Log.system);
428 }
429 MOD.langs[name] = langSetting;
430 return true;
431 }
432 }
433 return false;
434 }
435 }
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:437
void UpdateTalks(DirectoryInfo dir, string dirTemp)
Definition: ModPackage.cs:454
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 332 of file ModPackage.cs.

333 {
334 Mapping.RebuildLangModMapping(lang);
335 for (FileInfo fileInfo = Mapping.RelocateFile("SourceLocalization.json"); fileInfo != null; fileInfo = Mapping.RelocateFile("SourceLocalization.json"))
336 {
337 fileInfo.Delete();
338 Debug.Log("#source-localization deleted " + fileInfo.ShortPath());
339 }
340 Mapping.RebuildLangModMapping(Lang.langCode);
341 }
static string langCode
Definition: Lang.cs:29

References Debug, and Lang.langCode.

◆ CopyContentTo()

void ModPackage.CopyContentTo ( string  dir)
inline

Definition at line 19 of file ModPackage.cs.

20 {
22 IO.CopyAll(dirInfo.FullName, dir);
23 EClass.ui.Say(dir);
24 }
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.CreateCallbacks().

◆ ExportSourceLocalizations()

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

Definition at line 301 of file ModPackage.cs.

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

References $, Debug, and item.

Referenced by UpdateSourceLocalizationFile().

◆ GenerateCustomContentProfiles()

override void ModPackage.GenerateCustomContentProfiles ( )
inline

Definition at line 203 of file ModPackage.cs.

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

325 {
326 foreach (SourceData.BaseRow sourceRow in sourceRows)
327 {
328 sourceRow.ImportTexts(texts, sourceRow.UseAlias ? "alias" : "id");
329 }
330 }

◆ ParseLangMod()

void ModPackage.ParseLangMod ( DirectoryInfo  dir)
inline

Definition at line 161 of file ModPackage.cs.

162 {
163 if (Mapping == null)
164 {
165 Mapping = new FileMapping(dir.Parent);
166 }
167 Mapping.RebuildLangModMapping(EClass.core.config?.lang ?? EClass.core.debug.langCode.ToString());
168 Lang.excelDialog = null;
169 Debug.Log("LangMod: " + string.Join(", ", Mapping.OrderedLangMods));
170 if (Mapping.SourceSheets.Count > 0)
171 {
172 Debug.Log($"Source Sheets: {Mapping.SourceSheets.Count}, {Mapping.SourceLangMod}");
173 }
174 }
string lang
Definition: CoreConfig.cs:603
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 44 of file ModPackage.cs.

45 {
46 List<FileInfo> list = new List<FileInfo>();
47 FileInfo[] files = dir.GetFiles("*.z", SearchOption.TopDirectoryOnly);
48 foreach (FileInfo fileInfo in files)
49 {
50 string key = Path.ChangeExtension(fileInfo.Name, null);
51 if (addToList)
52 {
53 MOD.listMaps.Add(fileInfo);
54 }
55 maps[key] = fileInfo;
56 list.Add(fileInfo);
57 }
58 if (list.Count > 0)
59 {
60 Debug.Log($"Map: {maps.Count}");
61 }
62 return list;
63 }
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 65 of file ModPackage.cs.

66 {
67 List<FileInfo> list = new List<FileInfo>();
68 FileInfo[] files = dir.GetFiles("*.mp", SearchOption.TopDirectoryOnly);
69 foreach (FileInfo fileInfo in files)
70 {
71 string key = Path.ChangeExtension(fileInfo.Name, null);
72 if (addToList)
73 {
74 MOD.listPartialMaps.Add(fileInfo);
75 }
76 partialMaps[key] = fileInfo;
77 list.Add(fileInfo);
78 }
79 if (list.Count > 0)
80 {
81 Debug.Log($"PartialMap: {partialMaps.Count}");
82 }
83 return list;
84 }
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 123 of file ModPackage.cs.

124 {
125 List<FileInfo> list = new List<FileInfo>();
126 FileInfo[] files = dir.GetFiles("*.png", SearchOption.TopDirectoryOnly);
127 foreach (FileInfo fileInfo in files)
128 {
129 string name = fileInfo.Name;
130 if (name.StartsWith("BG_", StringComparison.Ordinal))
131 {
132 Portrait.modPortraitBGs.Add(fileInfo);
133 }
134 else if (name.StartsWith("BGF_", StringComparison.Ordinal))
135 {
136 Portrait.modPortraitBGFs.Add(fileInfo);
137 }
138 else if (name.EndsWith("-full.png", StringComparison.Ordinal))
139 {
140 Portrait.modFull.Add(fileInfo);
141 }
142 else if (name.EndsWith("-overlay.png", StringComparison.Ordinal))
143 {
144 Portrait.modOverlays.Add(fileInfo);
145 }
146 else
147 {
148 Portrait.modPortraits.Add(fileInfo);
149 }
150 Portrait.allIds.Add(name);
151 portraits[name] = fileInfo;
152 list.Add(fileInfo);
153 }
154 if (list.Count > 0)
155 {
156 Debug.Log($"Portrait: {portraits.Count}");
157 }
158 return list;
159 }
void Add(FileInfo fi, string path=null, string prefix="")
Definition: ModItemList.cs:85
static ModItemList< Sprite > modPortraitBGFs
Definition: Portrait.cs:8
static ModItemList< Sprite > modPortraitBGs
Definition: Portrait.cs:10
static ModItemList< Sprite > modOverlays
Definition: Portrait.cs:14
static ModItemList< Sprite > modPortraits
Definition: Portrait.cs:12
static HashSet< string > allIds
Definition: Portrait.cs:20
static ModItemList< Sprite > modFull
Definition: Portrait.cs:16

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 176 of file ModPackage.cs.

177 {
178 List<FileInfo> list = new List<FileInfo>();
179 FileInfo[] files = dir.GetFiles("*.*", SearchOption.AllDirectories);
180 foreach (FileInfo fileInfo in files)
181 {
182 if (ModUtil.GetAudioType(fileInfo.Extension) != AudioType.UNKNOWN)
183 {
184 string key = Path.ChangeExtension(Path.GetRelativePath(dir.FullName, fileInfo.FullName).NormalizePath(), null);
185 Dictionary<string, FileInfo> dictionary = MOD.sounds;
186 FileInfo value = (sounds[key] = fileInfo);
187 dictionary[key] = value;
188 list.Add(fileInfo);
189 }
190 }
191 if (list.Count > 0)
192 {
193 Debug.Log($"Sound: {sounds.Count}");
194 }
195 int num = sounds.Keys.Count((string k) => k.StartsWith("BGM/"));
196 if (num > 0)
197 {
198 Debug.Log($"BGM: {num}");
199 }
200 return list;
201 }
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 26 of file ModPackage.cs.

27 {
28 List<FileInfo> list = new List<FileInfo>();
29 FileInfo[] files = dir.GetFiles("*.xlsx", SearchOption.TopDirectoryOnly);
30 foreach (FileInfo fileInfo in files)
31 {
32 ExcelData excelData = new ExcelData(fileInfo.FullName);
33 TalkText.modList.Add(excelData);
34 talkTexts.Add(excelData);
35 list.Add(fileInfo);
36 }
37 if (list.Count > 0)
38 {
39 Debug.Log($"TalkText: {talkTexts.Count}");
40 }
41 return list;
42 }
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 103 of file ModPackage.cs.

104 {
105 List<FileInfo> list = new List<FileInfo>();
106 FileInfo[] files = dir.GetFiles("*.png", SearchOption.AllDirectories);
107 foreach (FileInfo fileInfo in files)
108 {
109 string key = Path.ChangeExtension(Path.GetRelativePath(dir.FullName, fileInfo.FullName).NormalizePath(), null);
110 string text = Path.ChangeExtension(fileInfo.FullName, null);
111 Dictionary<string, string> dictModItems = SpriteReplacer.dictModItems;
112 string value = (textures[key] = text);
113 dictModItems[key] = value;
114 list.Add(fileInfo);
115 }
116 if (list.Count > 0)
117 {
118 Debug.Log($"Texture: {textures.Count}");
119 }
120 return list;
121 }
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 86 of file ModPackage.cs.

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

References $, and Debug.

Referenced by ModManager.ParseExtra().

◆ UpdateDialogs()

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

Definition at line 437 of file ModPackage.cs.

438 {
439 DirectoryInfo[] directories = dir.GetDirectories();
440 foreach (DirectoryInfo directoryInfo in directories)
441 {
442 UpdateDialogs(directoryInfo, dirTemp + "/" + directoryInfo.Name);
443 }
444 FileInfo[] files = dir.GetFiles();
445 foreach (FileInfo fileInfo in files)
446 {
447 if (fileInfo.Name.EndsWith("xlsx"))
448 {
449 UpdateExcelBook(fileInfo, dirTemp, updateOnlyText: true);
450 }
451 }
452 }
void UpdateExcelBook(FileInfo f, string dirTemp, bool updateOnlyText)
Definition: ModPackage.cs:466

References UpdateDialogs(), and UpdateExcelBook().

Referenced by AddOrUpdateLang(), and UpdateDialogs().

◆ UpdateExcelBook()

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

Definition at line 466 of file ModPackage.cs.

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

References UpdateExcelSheet().

Referenced by UpdateDialogs(), and UpdateTalks().

◆ UpdateExcelSheet()

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

Definition at line 504 of file ModPackage.cs.

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

References Debug.

Referenced by UpdateExcelBook().

◆ UpdateSourceLocalizationFile()

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

Definition at line 343 of file ModPackage.cs.

344 {
345 if (!base.IsSourceLocalizable)
346 {
347 return null;
348 }
349 IReadOnlyDictionary<string, string> modEntries = SourceLocalization.GetModEntries(id, lang);
350 SortedDictionary<string, string> sortedDictionary = ExportSourceLocalizations();
351 SortedDictionary<string, string> final = new SortedDictionary<string, string>();
352 foreach (var (key, defaultValue) in sortedDictionary)
353 {
354 final[key] = modEntries.GetValueOrDefault(key, defaultValue);
355 }
356 string text3 = Path.Combine(dirInfo.FullName, "LangMod/" + lang + "/SourceLocalization.json");
357 if (force || modEntries.Count != final.Count || modEntries.Any((KeyValuePair<string, string> kv) => !final.ContainsKey(kv.Key)))
358 {
359 JsonSerializerSettings setting = new JsonSerializerSettings
360 {
361 PreserveReferencesHandling = PreserveReferencesHandling.None,
362 NullValueHandling = NullValueHandling.Ignore
363 };
364 IO.SaveFile(text3, final, compress: false, setting);
365 SourceLocalization.UpdateModEntries(id, lang, final);
366 }
367 return text3;
368 }
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:301

References ExportSourceLocalizations().

Referenced by LayerMod.CreateCallbacks().

◆ UpdateTalks()

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

Definition at line 454 of file ModPackage.cs.

455 {
456 FileInfo[] files = dir.GetFiles();
457 foreach (FileInfo fileInfo in files)
458 {
459 if (fileInfo.Name == "god_talk.xlsx" || fileInfo.Name == "chara_talk.xlsx")
460 {
461 UpdateExcelBook(fileInfo, dirTemp, updateOnlyText: false);
462 }
463 }
464 }

References UpdateExcelBook().

Referenced by AddOrUpdateLang().


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