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