Elin Modding Docs Doc
Loading...
Searching...
No Matches
ModManager.cs
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using System.Runtime.CompilerServices;
6using System.Text;
7using HeathenEngineering.SteamworksIntegration;
8using HeathenEngineering.SteamworksIntegration.API;
9using IniParser;
10using IniParser.Model;
11using NPOI.SS.UserModel;
12using NPOI.XSSF.UserModel;
13using Steamworks;
14using UnityEngine;
15using UnityEngine.Events;
16
17// Token: 0x020000B5 RID: 181
18[Serializable]
19public class ModManager : BaseModManager
20{
21 // Token: 0x17000106 RID: 262
22 // (get) Token: 0x060004BE RID: 1214 RVA: 0x00020D20 File Offset: 0x0001EF20
23 public static List<string> ListChainLoad
24 {
25 get
26 {
27 return BaseModManager.listChainLoad;
28 }
29 }
30
31 // Token: 0x17000107 RID: 263
32 // (get) Token: 0x060004BF RID: 1215 RVA: 0x00020D27 File Offset: 0x0001EF27
33 public static DirectoryInfo DirWorkshop
34 {
35 get
36 {
37 return BaseModManager.Instance.dirWorkshop;
38 }
39 }
40
41 // Token: 0x17000108 RID: 264
42 // (get) Token: 0x060004C0 RID: 1216 RVA: 0x00020D33 File Offset: 0x0001EF33
43 public static bool IsInitialized
44 {
45 get
46 {
47 return BaseModManager.isInitialized;
48 }
49 }
50
51 // Token: 0x17000109 RID: 265
52 // (get) Token: 0x060004C1 RID: 1217 RVA: 0x00020D3A File Offset: 0x0001EF3A
53 public static string PathIni
54 {
55 get
56 {
57 return CorePath.PathIni;
58 }
59 }
60
61 // Token: 0x060004C2 RID: 1218 RVA: 0x00020D44 File Offset: 0x0001EF44
62 public IniData GetElinIni()
63 {
64 FileIniDataParser fileIniDataParser = new FileIniDataParser();
65 if (!File.Exists(ModManager.PathIni))
66 {
67 File.CreateText(ModManager.PathIni).Close();
68 }
69 IniData iniData = fileIniDataParser.ReadFile(ModManager.PathIni, Encoding.UTF8);
70 if (iniData.GetKey("pass").IsEmpty())
71 {
72 string text = "";
73 for (int i = 0; i < 4; i++)
74 {
75 text += ModManager.PasswordChar.RandomItem<char>().ToString();
76 }
77 iniData.Global["pass"] = text;
78 fileIniDataParser.WriteFile(ModManager.PathIni, iniData, null);
79 }
80 return iniData;
81 }
82
83 // Token: 0x060004C3 RID: 1219 RVA: 0x00020DE0 File Offset: 0x0001EFE0
84 public override void Init(string path, string defaultPackage = "_Elona")
85 {
86 base.Init(path, defaultPackage);
87 IniData elinIni = this.GetElinIni();
88 if (BaseCore.IsOffline)
89 {
90 string key = elinIni.GetKey("path_workshop");
91 if (!key.IsEmpty())
92 {
93 this.dirWorkshop = new DirectoryInfo(key);
94 }
95 }
96 else
97 {
98 DirectoryInfo parent = new DirectoryInfo(App.Client.GetAppInstallDirectory(SteamSettings.behaviour.settings.applicationId)).Parent.Parent;
99 this.dirWorkshop = new DirectoryInfo(parent.FullName + "/workshop/content/2135150");
100 elinIni.Global["path_workshop"] = (this.dirWorkshop.FullName ?? "");
101 new FileIniDataParser().WriteFile(ModManager.PathIni, elinIni, null);
102 }
103 if (this.dirWorkshop != null && !this.dirWorkshop.Exists)
104 {
105 this.dirWorkshop = null;
106 }
107 Debug.Log("Mod Init:" + BaseModManager.rootDefaultPacakge);
108 this.packages.Clear();
109 DirectoryInfo[] directories = new DirectoryInfo(BaseModManager.rootMod).GetDirectories();
110 Array.Reverse<DirectoryInfo>(directories);
111 foreach (DirectoryInfo directoryInfo in directories)
112 {
113 if (!EClass.debug.skipMod || !Application.isEditor || !(directoryInfo.Name != "_Elona"))
114 {
115 this.AddPackage(directoryInfo, true);
116 }
117 }
118 }
119
120 // Token: 0x060004C4 RID: 1220 RVA: 0x00020F3C File Offset: 0x0001F13C
121 private void HandleResults(UgcQuery query)
122 {
123 foreach (WorkshopItem workshopItem in query.ResultsList)
124 {
125 if (workshopItem.IsSubscribed)
126 {
127 this.AddWorkshopPackage(workshopItem, false);
128 }
129 }
130 }
131
132 // Token: 0x060004C5 RID: 1221 RVA: 0x00020F9C File Offset: 0x0001F19C
133 public IEnumerator RefreshMods(Action onComplete, bool syncMods)
134 {
135 bool sync = !BaseCore.IsOffline && syncMods && UserGeneratedContent.Client.GetNumSubscribedItems() > 0U;
136 LoadingScreen loading = sync ? Util.Instantiate<LoadingScreen>("LoadingScreen", null) : null;
137 if (!EClass.debug.skipMod || !Application.isEditor)
138 {
139 if (sync)
140 {
141 UgcQuery activeQuery = UgcQuery.GetSubscribed(false, false, false, false, 0U);
142 activeQuery.Execute(new UnityAction<UgcQuery>(this.HandleResults));
143 LoadingScreen loadingScreen = loading;
144 if (loadingScreen != null)
145 {
146 loadingScreen.Log("Fetching subscripted Mods...(Hit ESC to cancel)");
147 }
148 while (activeQuery.handle != UGCQueryHandle_t.Invalid && !UnityEngine.Input.GetKey(KeyCode.Escape))
149 {
150 yield return new WaitForEndOfFrame();
151 }
152 activeQuery = null;
153 }
154 else
155 {
156 LoadingScreen loadingScreen2 = loading;
157 if (loadingScreen2 != null)
158 {
159 loadingScreen2.Log("Fetching offline Mods.");
160 }
161 if (this.dirWorkshop != null)
162 {
163 foreach (DirectoryInfo dir in this.dirWorkshop.GetDirectories())
164 {
165 this.AddPackage(dir, false);
166 }
167 }
168 }
169 }
170 if (sync)
171 {
172 bool valid = false;
173 while (!valid)
174 {
175 valid = true;
176 foreach (BaseModPackage baseModPackage in this.packages)
177 {
178 WorkshopItem workshopItem = baseModPackage.item as WorkshopItem;
179 if (!baseModPackage.installed && workshopItem != null && !workshopItem.IsBanned)
180 {
181 valid = false;
182 string text = "Downloading " + workshopItem.Title + ": ";
183 if (!baseModPackage.progressText)
184 {
185 baseModPackage.progressText = loading.Log(text);
186 }
187 if (baseModPackage.downloadStarted && workshopItem.DownloadCompletion >= 1f)
188 {
189 baseModPackage.progressText.text = text + "Done!";
190 baseModPackage.installed = true;
191 }
192 else if (workshopItem.IsDownloading || workshopItem.IsDownloadPending)
193 {
194 baseModPackage.progressText.text = text + ((int)(workshopItem.DownloadCompletion * 100f)).ToString() + "%";
195 }
196 else if (!baseModPackage.downloadStarted)
197 {
198 baseModPackage.downloadStarted = true;
199 workshopItem.DownloadItem(true);
200 Debug.Log(string.Concat(new string[]
201 {
202 "start downloading:",
203 workshopItem.Title,
204 "/",
205 workshopItem.IsInstalled.ToString(),
206 "/",
207 baseModPackage.installed.ToString(),
208 "/",
209 workshopItem.IsDownloading.ToString(),
210 "/",
211 workshopItem.IsDownloadPending.ToString(),
212 "/",
213 workshopItem.DownloadCompletion.ToString()
214 }));
215 }
216 }
217 }
218 if (!valid && UnityEngine.Input.GetKey(KeyCode.Escape))
219 {
220 break;
221 }
222 yield return new WaitForEndOfFrame();
223 }
224 }
225 foreach (BaseModPackage baseModPackage2 in this.packages)
226 {
227 baseModPackage2.Init();
228 Debug.Log(string.Concat(new string[]
229 {
230 baseModPackage2.title,
231 "/",
232 baseModPackage2.id,
233 "/",
234 baseModPackage2.installed.ToString(),
235 "/",
236 baseModPackage2.dirInfo.FullName
237 }));
238 }
239 this.LoadLoadOrder();
240 this.packages.Sort((BaseModPackage a, BaseModPackage b) => a.loadPriority - b.loadPriority);
241 foreach (BaseModPackage baseModPackage3 in this.packages)
242 {
243 if (!baseModPackage3.isInPackages && baseModPackage3.willActivate)
244 {
245 foreach (BaseModPackage baseModPackage4 in this.packages)
246 {
247 if (baseModPackage4.isInPackages && baseModPackage3.id == baseModPackage4.id)
248 {
249 baseModPackage4.hasPublishedPackage = true;
250 }
251 }
252 }
253 }
254 LoadingScreen loadingScreen3 = loading;
255 if (loadingScreen3 != null)
256 {
257 loadingScreen3.Log("Total number of Mods:" + this.packages.Count.ToString());
258 }
259 if (loading)
260 {
261 loading.Log("Activating Mods...");
262 yield return new WaitForEndOfFrame();
263 yield return new WaitForEndOfFrame();
264 }
265 BaseModManager.listChainLoad.Clear();
266 ModManager.ListPluginObject.Clear();
267 foreach (BaseModPackage baseModPackage5 in this.packages)
268 {
269 if (baseModPackage5.IsValidVersion())
270 {
271 baseModPackage5.Activate();
272 if (baseModPackage5.activated)
273 {
274 BaseModManager.listChainLoad.Add(baseModPackage5.dirInfo.FullName);
275 }
276 }
277 }
278 BaseModManager.isInitialized = true;
279 yield return new WaitForEndOfFrame();
280 if (onComplete != null)
281 {
282 onComplete();
283 }
284 if (loading)
285 {
286 UnityEngine.Object.Destroy(loading.gameObject);
287 }
288 yield return null;
289 yield break;
290 }
291
292 // Token: 0x060004C6 RID: 1222 RVA: 0x00020FBC File Offset: 0x0001F1BC
293 public void SaveLoadOrder()
294 {
295 List<string> list = new List<string>();
296 foreach (BaseModPackage baseModPackage in this.packages)
297 {
298 if (!baseModPackage.builtin && Directory.Exists(baseModPackage.dirInfo.FullName))
299 {
300 string item = baseModPackage.dirInfo.FullName + "," + (baseModPackage.willActivate ? 1 : 0).ToString();
301 list.Add(item);
302 }
303 }
304 File.WriteAllLines(CorePath.rootExe + "loadorder.txt", list);
305 }
306
307 // Token: 0x060004C7 RID: 1223 RVA: 0x00021070 File Offset: 0x0001F270
308 public void LoadLoadOrder()
309 {
310 string path = CorePath.rootExe + "loadorder.txt";
311 if (!File.Exists(path))
312 {
313 return;
314 }
315 Dictionary<string, BaseModPackage> dictionary = new Dictionary<string, BaseModPackage>();
316 foreach (BaseModPackage baseModPackage in this.packages)
317 {
318 if (!baseModPackage.builtin)
319 {
320 dictionary[baseModPackage.dirInfo.FullName] = baseModPackage;
321 }
322 }
323 int num = 0;
324 string[] array = File.ReadAllLines(path);
325 for (int i = 0; i < array.Length; i++)
326 {
327 string[] array2 = array[i].Split(',', StringSplitOptions.None);
328 if (dictionary.ContainsKey(array2[0]))
329 {
330 BaseModPackage baseModPackage2 = dictionary[array2[0]];
331 baseModPackage2.loadPriority = num;
332 baseModPackage2.willActivate = (array2[1] == "1");
333 }
334 num++;
335 }
336 }
337
338 // Token: 0x060004C8 RID: 1224 RVA: 0x0002115C File Offset: 0x0001F35C
339 public ModPackage AddPackage(DirectoryInfo dir, bool isInPackages = false)
340 {
341 ModPackage modPackage = new ModPackage
342 {
343 dirInfo = dir,
344 installed = true
345 };
346 this.packages.Add(modPackage);
347 modPackage.isInPackages = isInPackages;
348 modPackage.loadPriority = this.priorityIndex;
349 this.priorityIndex++;
350 return modPackage;
351 }
352
353 // Token: 0x060004C9 RID: 1225 RVA: 0x000211AC File Offset: 0x0001F3AC
354 public ModPackage AddWorkshopPackage(WorkshopItem item, bool isInPackages = false)
355 {
356 ulong num;
357 string path;
358 DateTime dateTime;
359 UserGeneratedContent.Client.GetItemInstallInfo(item.FileId, out num, out path, out dateTime);
360 DirectoryInfo directoryInfo = new DirectoryInfo(path);
361 ModPackage modPackage = new ModPackage
362 {
363 item = item,
364 dirInfo = directoryInfo,
365 installed = directoryInfo.Exists,
366 banned = item.IsBanned
367 };
368 this.packages.Add(modPackage);
369 modPackage.isInPackages = isInPackages;
370 modPackage.loadPriority = this.priorityIndex;
371 this.priorityIndex++;
372 return modPackage;
373 }
374
375 // Token: 0x060004CA RID: 1226 RVA: 0x00021234 File Offset: 0x0001F434
376 public override void ParseExtra(DirectoryInfo dir, BaseModPackage package)
377 {
378 string name = dir.Name;
379 uint num = <PrivateImplementationDetails>.ComputeStringHash(name);
380 if (num <= 1151856721U)
381 {
382 if (num != 688467962U)
383 {
384 if (num != 1054589944U)
385 {
386 if (num != 1151856721U)
387 {
388 return;
389 }
390 if (!(name == "Map"))
391 {
392 return;
393 }
394 if (!package.builtin)
395 {
396 foreach (FileInfo fileInfo in dir.GetFiles())
397 {
398 if (fileInfo.Name.EndsWith(".z"))
399 {
400 MOD.listMaps.Add(fileInfo);
401 }
402 }
403 return;
404 }
405 }
406 else
407 {
408 if (!(name == "TalkText"))
409 {
410 return;
411 }
412 foreach (FileInfo fileInfo2 in dir.GetFiles())
413 {
414 if (fileInfo2.Name.EndsWith(".xlsx"))
415 {
416 TalkText.modList.Add(new ExcelData(fileInfo2.FullName));
417 }
418 }
419 return;
420 }
421 }
422 else
423 {
424 if (!(name == "Portrait"))
425 {
426 return;
427 }
428 foreach (FileInfo fileInfo3 in dir.GetFiles())
429 {
430 if (fileInfo3.Name.EndsWith(".png"))
431 {
432 if (fileInfo3.Name.StartsWith("BG_"))
433 {
434 Portrait.modPortraitBGs.Add(fileInfo3, null, "");
435 }
436 else if (fileInfo3.Name.StartsWith("BGF_"))
437 {
438 Portrait.modPortraitBGFs.Add(fileInfo3, null, "");
439 }
440 else if (fileInfo3.Name.EndsWith("-full.png"))
441 {
442 Portrait.modFull.Add(fileInfo3, null, "");
443 }
444 else if (fileInfo3.Name.EndsWith("-overlay.png"))
445 {
446 Portrait.modOverlays.Add(fileInfo3, null, "");
447 }
448 else
449 {
450 Portrait.modPortraits.Add(fileInfo3, null, "");
451 }
452 Portrait.allIds.Add(fileInfo3.Name);
453 }
454 }
455 return;
456 }
457 }
458 else if (num <= 2571916692U)
459 {
460 if (num != 2026591700U)
461 {
462 if (num != 2571916692U)
463 {
464 return;
465 }
466 if (!(name == "Texture"))
467 {
468 return;
469 }
470 foreach (FileInfo fileInfo4 in dir.GetFiles())
471 {
472 if (fileInfo4.Name.EndsWith(".png"))
473 {
474 SpriteReplacer.dictModItems[fileInfo4.Name.Replace(".png", "")] = fileInfo4.GetFullFileNameWithoutExtension();
475 }
476 }
477 return;
478 }
479 else
480 {
481 if (!(name == "Texture Replace"))
482 {
483 return;
484 }
485 foreach (FileInfo fileInfo5 in dir.GetFiles())
486 {
487 if (fileInfo5.Name.EndsWith(".png"))
488 {
489 this.replaceFiles.Add(fileInfo5);
490 }
491 }
492 return;
493 }
494 }
495 else if (num != 3658367683U)
496 {
497 if (num != 4044785525U)
498 {
499 return;
500 }
501 if (!(name == "Lang"))
502 {
503 return;
504 }
505 foreach (DirectoryInfo directoryInfo in dir.GetDirectories())
506 {
507 if (!directoryInfo.Name.StartsWith("_") && !this.<ParseExtra>g__TryAddLang|19_0(directoryInfo, false))
508 {
509 Debug.Log("Generating Language Mod Contents:" + directoryInfo.FullName);
510 IO.CopyDir(CorePath.packageCore + "Lang/EN", directoryInfo.FullName, null);
511 Directory.CreateDirectory(directoryInfo.FullName + "/Dialog");
512 IO.CopyDir(CorePath.packageCore + "Lang/_Dialog", directoryInfo.FullName + "/Dialog", null);
513 EClass.sources.ExportSourceTexts(directoryInfo.FullName + "/Game");
514 IO.Copy(CorePath.packageCore + "Lang/lang.ini", directoryInfo.FullName + "/");
515 this.<ParseExtra>g__TryAddLang|19_0(directoryInfo, true);
516 }
517 }
518 }
519 else
520 {
521 if (!(name == "Map Piece"))
522 {
523 return;
524 }
525 if (!package.builtin)
526 {
527 foreach (FileInfo fileInfo6 in dir.GetFiles())
528 {
529 if (fileInfo6.Name.EndsWith(".mp"))
530 {
531 MOD.listPartialMaps.Add(fileInfo6);
532 }
533 }
534 return;
535 }
536 }
537 }
538
539 // Token: 0x060004CB RID: 1227 RVA: 0x0002166C File Offset: 0x0001F86C
540 public void UpdateDialogs(DirectoryInfo dir, string dirTemp)
541 {
542 foreach (DirectoryInfo directoryInfo in dir.GetDirectories())
543 {
544 this.UpdateDialogs(directoryInfo, dirTemp + "/" + directoryInfo.Name);
545 }
546 foreach (FileInfo fileInfo in dir.GetFiles())
547 {
548 if (fileInfo.Name.EndsWith("xlsx"))
549 {
550 this.UpdateExcelBook(fileInfo, dirTemp, true);
551 }
552 }
553 }
554
555 // Token: 0x060004CC RID: 1228 RVA: 0x000216E4 File Offset: 0x0001F8E4
556 public void UpdateTalks(DirectoryInfo dir, string dirTemp)
557 {
558 foreach (FileInfo fileInfo in dir.GetFiles())
559 {
560 if (fileInfo.Name == "god_talk.xlsx" || fileInfo.Name == "chara_talk.xlsx")
561 {
562 this.UpdateExcelBook(fileInfo, dirTemp, false);
563 }
564 }
565 }
566
567 // Token: 0x060004CD RID: 1229 RVA: 0x00021738 File Offset: 0x0001F938
568 public void UpdateExcelBook(FileInfo f, string dirTemp, bool updateOnlyText)
569 {
570 string path = dirTemp + "/" + f.Name;
571 if (!File.Exists(path))
572 {
573 return;
574 }
575 XSSFWorkbook xssfworkbook;
576 using (FileStream fileStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
577 {
578 xssfworkbook = new XSSFWorkbook(fileStream);
579 }
580 XSSFWorkbook xssfworkbook2;
581 using (FileStream fileStream2 = File.Open(f.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
582 {
583 xssfworkbook2 = new XSSFWorkbook(fileStream2);
584 }
585 for (int i = 0; i < xssfworkbook2.NumberOfSheets; i++)
586 {
587 ISheet sheetAt = xssfworkbook2.GetSheetAt(i);
588 ISheet sheet = xssfworkbook.GetSheet(sheetAt.SheetName);
589 if (sheet == null)
590 {
591 Log.system = Log.system + "Old sheet not found:" + sheetAt.SheetName + Environment.NewLine;
592 }
593 else
594 {
595 int num = this.UpdateExcelSheet(sheetAt, sheet, updateOnlyText);
596 Log.system = string.Concat(new string[]
597 {
598 Log.system,
599 (num == 0) ? "(No Changes) " : "(Updated) ",
600 f.FullName,
601 "(",
602 sheetAt.SheetName,
603 ")",
604 Environment.NewLine
605 });
606 if (num != 0)
607 {
608 Log.system = Log.system + num.ToString() + Environment.NewLine;
609 }
610 Log.system += Environment.NewLine;
611 }
612 }
613 using (FileStream fileStream3 = new FileStream(f.FullName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
614 {
615 xssfworkbook2.Write(fileStream3);
616 }
617 }
618
619 // Token: 0x060004CE RID: 1230 RVA: 0x000218E4 File Offset: 0x0001FAE4
620 public int UpdateExcelSheet(ISheet destSheet, ISheet oldSheet, bool updateOnlytext)
621 {
622 Dictionary<string, string[]> dictionary = new Dictionary<string, string[]>();
623 int num = 0;
624 int num2 = 0;
625 int num3 = 10;
626 IRow row = destSheet.GetRow(0);
627 IRow row2 = oldSheet.GetRow(0);
628 List<ModManager.SheetIndex> list = new List<ModManager.SheetIndex>();
629 int cellnum = ModManager.<UpdateExcelSheet>g__FindField|24_0(row, "id");
630 int cellnum2 = ModManager.<UpdateExcelSheet>g__FindField|24_0(row2, "id");
631 for (int i = 0; i < (int)row.LastCellNum; i++)
632 {
633 ICell cell = row.GetCell(i);
634 if (cell == null)
635 {
636 break;
637 }
638 string stringCellValue = cell.StringCellValue;
639 if (!(stringCellValue == "id") && (!updateOnlytext || !(stringCellValue != "text")))
640 {
641 for (int j = 0; j < (int)row2.LastCellNum; j++)
642 {
643 cell = row2.GetCell(j);
644 if (cell == null)
645 {
646 break;
647 }
648 if (cell.StringCellValue == stringCellValue)
649 {
650 list.Add(new ModManager.SheetIndex
651 {
652 dest = i,
653 old = j
654 });
655 Debug.Log(string.Concat(new string[]
656 {
657 destSheet.SheetName,
658 "/",
659 stringCellValue,
660 "/",
661 i.ToString(),
662 "/",
663 j.ToString()
664 }));
665 break;
666 }
667 }
668 }
669 }
670 for (int k = 2; k <= oldSheet.LastRowNum; k++)
671 {
672 IRow row3 = oldSheet.GetRow(k);
673 if (row3 == null)
674 {
675 if (num2 >= num3)
676 {
677 break;
678 }
679 num2++;
680 }
681 else
682 {
683 num2 = 0;
684 ICell cell2 = row3.GetCell(cellnum2);
685 if (cell2 != null)
686 {
687 string text = (cell2.CellType == CellType.Numeric) ? cell2.NumericCellValue.ToString() : cell2.StringCellValue;
688 if (!text.IsEmpty())
689 {
690 string[] array = new string[list.Count];
691 for (int l = 0; l < list.Count; l++)
692 {
693 ICell cell3 = row3.GetCell(list[l].old);
694 if (cell3 != null)
695 {
696 string stringCellValue2 = cell3.StringCellValue;
697 if (!stringCellValue2.IsEmpty())
698 {
699 array[l] = stringCellValue2;
700 }
701 }
702 }
703 dictionary.Add(text, array);
704 }
705 }
706 }
707 }
708 num2 = 0;
709 for (int m = 2; m <= destSheet.LastRowNum; m++)
710 {
711 IRow row4 = destSheet.GetRow(m);
712 if (row4 == null)
713 {
714 if (num2 >= num3)
715 {
716 break;
717 }
718 num2++;
719 }
720 else
721 {
722 num2 = 0;
723 ICell cell4 = row4.GetCell(cellnum);
724 if (cell4 != null)
725 {
726 string text2 = (cell4.CellType == CellType.Numeric) ? cell4.NumericCellValue.ToString() : cell4.StringCellValue;
727 if (!text2.IsEmpty() && dictionary.ContainsKey(text2))
728 {
729 string[] array2 = dictionary[text2];
730 for (int n = 0; n < list.Count; n++)
731 {
732 ICell cell5 = row4.GetCell(list[n].dest) ?? row4.CreateCell(list[n].dest, CellType.String);
733 if (cell5 != null)
734 {
735 cell5.SetCellValue(array2[n]);
736 cell5.SetCellType(CellType.String);
737 cell5.SetAsActiveCell();
738 num++;
739 }
740 }
741 }
742 }
743 }
744 }
745 return num;
746 }
747
748 // Token: 0x060004D1 RID: 1233 RVA: 0x00021C3C File Offset: 0x0001FE3C
749 [CompilerGenerated]
750 private bool <ParseExtra>g__TryAddLang|19_0(DirectoryInfo dirLang, bool isNew)
751 {
752 string name = dirLang.Name;
753 foreach (FileInfo fileInfo in dirLang.GetFiles())
754 {
755 if (fileInfo.Name == "lang.ini")
756 {
757 LangSetting langSetting = new LangSetting(fileInfo.FullName)
758 {
759 id = name,
760 dir = dirLang.FullName + "/"
761 };
762 if (isNew)
763 {
764 langSetting.SetVersion();
765 }
766 else if (Application.isEditor && !Lang.IsBuiltin(dirLang.Name) && langSetting.GetVersion() != EClass.core.version.GetInt())
767 {
768 EClass.sources.Init();
769 Log.system = "Updated Language Files:" + Environment.NewLine + Environment.NewLine;
770 Debug.Log(string.Concat(new string[]
771 {
772 "Updating Language:",
773 langSetting.name,
774 "/",
775 langSetting.GetVersion().ToString(),
776 "/",
777 EClass.core.version.GetInt().ToString()
778 }));
779 string text = dirLang.FullName + "/Game";
780 Directory.Move(text, text + "_temp");
781 EClass.sources.ExportSourceTexts(text);
782 EClass.sources.UpdateSourceTexts(text);
783 IO.DeleteDirectory(text + "_temp");
784 text = dirLang.FullName + "/Dialog";
785 Directory.Move(text, text + "_temp");
786 IO.CopyDir(CorePath.packageCore + "Lang/_Dialog", text, null);
787 this.UpdateDialogs(new DirectoryInfo(text), text + "_temp");
788 IO.DeleteDirectory(text + "_temp");
789 text = dirLang.FullName + "/Data";
790 IO.CopyDir(text, text + "_temp", null);
791 IO.Copy(CorePath.packageCore + "Lang/EN/Data/god_talk.xlsx", text);
792 IO.Copy(CorePath.packageCore + "Lang/EN/Data/chara_talk.xlsx", text);
793 this.UpdateTalks(new DirectoryInfo(text), text + "_temp");
794 IO.DeleteDirectory(text + "_temp");
795 langSetting.SetVersion();
796 IO.SaveText(dirLang.FullName + "/update.txt", Log.system);
797 }
798 MOD.langs[name] = langSetting;
799 return true;
800 }
801 }
802 return false;
803 }
804
805 // Token: 0x060004D2 RID: 1234 RVA: 0x00021ED8 File Offset: 0x000200D8
806 [CompilerGenerated]
807 internal static int <UpdateExcelSheet>g__FindField|24_0(IRow row, string id)
808 {
809 for (int i = 0; i < (int)row.LastCellNum; i++)
810 {
811 ICell cell = row.GetCell(i);
812 if (cell == null)
813 {
814 break;
815 }
816 if (cell.StringCellValue == id)
817 {
818 return i;
819 }
820 }
821 return -1;
822 }
823
824 // Token: 0x0400064D RID: 1613
825 public static readonly string PasswordChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
826
827 // Token: 0x0400064E RID: 1614
828 public static List<object> ListPluginObject = new List<object>();
829
830 // Token: 0x0400064F RID: 1615
831 public List<FileInfo> replaceFiles = new List<FileInfo>();
832
833 // Token: 0x02000803 RID: 2051
834 public struct SheetIndex
835 {
836 // Token: 0x04002282 RID: 8834
837 public int dest;
838
839 // Token: 0x04002283 RID: 8835
840 public int old;
841 }
842}