Elin Decompiled Documentation EA 23.199 Nightly
Loading...
Searching...
No Matches
SourceAsset.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.IO;
3using UnityEngine;
4
5public class SourceAsset : EScriptable
6{
7 public class PrefData
8 {
9 public Dictionary<string, SourcePref> dict = new Dictionary<string, SourcePref>();
10 }
11
12 public class Prefs
13 {
14 public int version;
15
16 public PrefData things = new PrefData();
17
18 public PrefData charas = new PrefData();
19 }
20
21 public string idLoad = "prefs";
22
24
25 public static string PrefPath => Application.dataPath + "/Resources/Data/Export/";
26
27 public void DoFix()
28 {
29 }
30
31 public void SavePrefs(string id = "prefs")
32 {
33 _SavePrefs(id);
34 }
35
36 public static void _SavePrefs(string id = "prefs")
37 {
38 if (File.Exists(PrefPath + id))
39 {
40 IO.CopyAs(PrefPath + id, PrefPath + id + "_bk");
41 }
42 Prefs prefs = new Prefs();
43 prefs.version = 2;
44 Debug.Log(EClass.sources.things.rows.Count);
45 Debug.Log(EClass.sources.charas.rows.Count);
46 foreach (SourceThing.Row row in EClass.sources.things.rows)
47 {
48 if (prefs.things.dict.ContainsKey(row.id))
49 {
50 Debug.LogError("exception: duplicate id:" + row.id + "/" + row.name);
51 }
52 else
53 {
54 prefs.things.dict.Add(row.id, row.pref);
55 }
56 }
57 foreach (SourceChara.Row row2 in EClass.sources.charas.rows)
58 {
59 if (prefs.charas.dict.ContainsKey(row2.id))
60 {
61 Debug.LogError("exception: duplicate id:" + row2.id + "/" + row2.name);
62 }
63 else
64 {
65 prefs.charas.dict.Add(row2.id, row2.pref);
66 }
67 }
68 IO.SaveFile(PrefPath + id, prefs);
69 Debug.Log("Exported Prefs:" + id);
70 }
71
72 public void LoadPrefs()
73 {
75 }
76
77 public void LoadPrefs_bk()
78 {
80 }
81
82 public static void _LoadPrefs(string id = "prefs")
83 {
84 IO.CopyAs(PrefPath + id, PrefPath + id + "_loadbk");
85 Prefs prefs = IO.LoadFile<Prefs>(PrefPath + id);
86 Debug.Log(prefs);
87 foreach (SourceThing.Row row in EClass.sources.things.rows)
88 {
89 if (prefs.things.dict.ContainsKey(row.id))
90 {
91 row.pref = prefs.things.dict[row.id];
92 }
93 if (prefs.version == 0)
94 {
95 row.pref.y = 0f;
96 }
97 }
98 foreach (SourceChara.Row row2 in EClass.sources.charas.rows)
99 {
100 if (prefs.charas.dict.ContainsKey(row2.id))
101 {
102 row2.pref = prefs.charas.dict[row2.id];
103 }
104 }
105 Debug.Log("Imported Prefs:" + id);
106 }
107}
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
Dictionary< string, SourcePref > dict
Definition: SourceAsset.cs:9
UD_String_String renames
Definition: SourceAsset.cs:23
void DoFix()
Definition: SourceAsset.cs:27
string idLoad
Definition: SourceAsset.cs:21
static string PrefPath
Definition: SourceAsset.cs:25
void LoadPrefs()
Definition: SourceAsset.cs:72
void SavePrefs(string id="prefs")
Definition: SourceAsset.cs:31
static void _SavePrefs(string id="prefs")
Definition: SourceAsset.cs:36
static void _LoadPrefs(string id="prefs")
Definition: SourceAsset.cs:82
void LoadPrefs_bk()
Definition: SourceAsset.cs:77
SourceThing things
SourceChara charas