Elin Modding Docs Doc
Loading...
Searching...
No Matches
TextureManager.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4
5// Token: 0x02000131 RID: 305
6public class TextureManager
7{
8 // Token: 0x170001C7 RID: 455
9 // (get) Token: 0x06000827 RID: 2087 RVA: 0x0003597C File Offset: 0x00033B7C
10 public string pathTex
11 {
12 get
13 {
14 return CorePath.packageCore + "Texture/";
15 }
16 }
17
18 // Token: 0x06000828 RID: 2088 RVA: 0x00035990 File Offset: 0x00033B90
19 public void Init()
20 {
21 BaseTileMap tileMap = EClass.scene.screenElin.tileMap;
22 CoreRef.TextureDatas textureData = EClass.core.refs.textureData;
23 this.AddBase(textureData.block, "blocks.png", tileMap.passBlock, "_MainTex");
24 this.AddBase(textureData.floor, "floors.png", tileMap.passFloor, "_MainTex");
25 this.AddBase(textureData.objs_SS, "objs_SS.png", tileMap.passObjSS, "_MainTex");
26 this.AddBase(textureData.objs_S, "objs_S.png", tileMap.passObjS, "_MainTex");
27 this.AddBase(textureData.objs, "objs.png", tileMap.passObj, "_MainTex");
28 this.AddBase(textureData.objs_L, "objs_L.png", tileMap.passObjL, "_MainTex");
29 this.AddBase(textureData.roofs, "roofs.png", tileMap.passRoof, "_MainTex");
30 this.AddBase(textureData.shadows, "shadows.png", tileMap.passShadow, "_MainTex");
31 this.AddBase(textureData.fov, "fov.png", tileMap.passFov, "_MainTex");
32 this.AddBase(textureData.objs_C, "objs_C.png", tileMap.passChara, "_MainTex");
33 this.AddBase(textureData.objs_CLL, "objs_CLL.png", tileMap.passCharaLL, "_MainTex");
34 this.AddBase(textureData.block_snow, "blocks_snow.png", tileMap.passBlock.snowPass, "_MainTex");
35 this.AddBase(textureData.floor_snow, "floors_snow.png", tileMap.passFloor.snowPass, "_MainTex");
36 this.AddBase(textureData.objs_S_snow, "objs_S_snow.png", tileMap.passObjS.snowPass, "_MainTex");
37 this.AddBase(textureData.objs_snow, "objs_snow.png", tileMap.passObj.snowPass, "_MainTex");
38 this.AddBase(textureData.objs_L_snow, "objs_L_snow.png", tileMap.passObjL.snowPass, "_MainTex");
39 this.Add(tileMap.passRamp, textureData.block, "_MainTex");
40 this.Add(tileMap.passWaterBlock, textureData.block, "_MainTex");
41 this.Add(tileMap.passFog, textureData.block, "_MainTex");
42 this.Add(tileMap.passLiquid, textureData.block, "_MainTex");
43 this.Add(tileMap.passBlockEx, textureData.block, "_MainTex");
44 this.Add(tileMap.passInner, textureData.block, "_MainTex");
45 this.Add(tileMap.passBlockMarker, textureData.block, "_MainTex");
46 this.Add(tileMap.passEdge, textureData.floor, "_MainTex");
47 this.Add(tileMap.passFloorEx, textureData.floor, "_MainTex");
48 this.Add(tileMap.passFloorWater, textureData.floor, "_MainTex");
49 this.Add(tileMap.passAutoTile, textureData.floor, "_MainTex");
50 this.Add(tileMap.passShore, textureData.floor, "_MainTex");
51 this.Add(tileMap.passAutoTileWater, textureData.floor, "_MainTex");
52 this.Add(tileMap.passFloorMarker, textureData.floor, "_MainTex");
53 this.Add(tileMap.passCharaL, textureData.objs_C, "_MainTex");
54 this.Add(tileMap.passIcon, textureData.objs_S, "_MainTex");
55 this.AddList(textureData.world, "world.png");
56 this.AddList(textureData.bird, "bird1.png");
57 foreach (FileInfo fileInfo in new DirectoryInfo(CorePath.user + "/Texture Replace").GetFiles())
58 {
59 if (fileInfo.Name.EndsWith(".png"))
60 {
61 this.TryAddReplace(fileInfo, TextureReplace.Source.User, true, false);
62 }
63 }
64 foreach (FileInfo file in EClass.core.mods.replaceFiles)
65 {
66 this.TryAddReplace(file, TextureReplace.Source.Mod, true, false);
67 }
68 }
69
70 // Token: 0x06000829 RID: 2089 RVA: 0x00035DCC File Offset: 0x00033FCC
71 public void AddBase(TextureData data, string path, MeshPass pass, string texName = "_MainTex")
72 {
73 this.texMap[data.id] = data;
74 data.path = this.pathTex + path;
75 data.texName = texName;
76 data.dictReplace.Clear();
77 data.tileW = data.tex.width / (int)pass.pmesh.tiling.x;
78 data.tileH = data.tex.height / (int)pass.pmesh.tiling.y;
79 this.texMap[data.id].listPass.Add(pass);
80 }
81
82 // Token: 0x0600082A RID: 2090 RVA: 0x00035E72 File Offset: 0x00034072
83 public void Add(MeshPass to, TextureData from, string texName = "_MainTex")
84 {
85 this.texMap[from.id].listPass.Add(to);
86 }
87
88 // Token: 0x0600082B RID: 2091 RVA: 0x00035E90 File Offset: 0x00034090
89 public void AddList(TextureData data, string path)
90 {
91 data.path = this.pathTex + path;
92 this.texMap[data.id] = data;
93 }
94
95 // Token: 0x0600082C RID: 2092 RVA: 0x00035EB8 File Offset: 0x000340B8
96 public void RefreshTextures()
97 {
98 foreach (TextureData textureData in this.texMap.Values)
99 {
100 textureData.TryRefresh();
101 }
102 if (EClass.core.IsGameStarted && EClass._zone != null && EClass._zone.isStarted)
103 {
104 EClass.scene.ApplyZoneConfig();
105 }
106 }
107
108 // Token: 0x0600082D RID: 2093 RVA: 0x00035F38 File Offset: 0x00034138
109 public void OnDropFile(List<string> paths)
110 {
111 int num = 0;
112 foreach (string fileName in paths)
113 {
114 FileInfo fileInfo = new FileInfo(fileName);
115 if (this.TryAddReplace(fileInfo, TextureReplace.Source.User, false, false))
116 {
117 string text = CorePath.user + "/Texture Replace/" + fileInfo.Name;
118 try
119 {
120 if (File.Exists(text))
121 {
122 File.Delete(text);
123 }
124 fileInfo.CopyTo(text, true);
125 }
126 catch (Exception)
127 {
128 }
129 this.TryAddReplace(new FileInfo(text), TextureReplace.Source.User, true, true);
130 num++;
131 }
132 }
133 Msg.Say("Imported " + num.ToString() + "image(s)");
134 }
135
136 // Token: 0x0600082E RID: 2094 RVA: 0x00036000 File Offset: 0x00034200
137 public bool TryAddReplace(FileInfo file, TextureReplace.Source source = TextureReplace.Source.Mod, bool add = true, bool refresh = false)
138 {
139 string[] array = Path.GetFileNameWithoutExtension(file.Name).Split('_', StringSplitOptions.None);
140 if (array.Length == 1)
141 {
142 return false;
143 }
144 string key = array[0];
145 int index;
146 if (!int.TryParse(array[1], out index))
147 {
148 return false;
149 }
150 if (!this.texMap.ContainsKey(key))
151 {
152 return false;
153 }
154 TextureData textureData = this.texMap[key];
155 if (textureData.listPass.Count == 0)
156 {
157 return false;
158 }
159 if (add)
160 {
161 textureData.AddReplace(new TextureReplace
162 {
163 file = file,
164 index = index,
165 data = textureData,
166 source = source
167 });
168 if (refresh)
169 {
170 textureData.TryRefresh();
171 }
172 }
173 return true;
174 }
175
176 // Token: 0x0600082F RID: 2095 RVA: 0x0003609C File Offset: 0x0003429C
177 public void ApplyLocalReplace(string path)
178 {
179 foreach (TextureData textureData in this.texMap.Values)
180 {
181 if (textureData.listReplaceLocal.Count > 0)
182 {
183 textureData.forceRefresh = true;
184 foreach (TextureReplace textureReplace in textureData.listReplaceLocal)
185 {
186 textureReplace.DestoryTex();
187 if (textureReplace.original != null)
188 {
189 textureData.dictReplace[textureReplace.index] = textureReplace.original;
190 }
191 else
192 {
193 textureData.dictReplace.Remove(textureReplace.index);
194 }
195 }
196 }
197 textureData.listReplaceLocal.Clear();
198 }
199 string path2 = path + "Texture Replace";
200 if (Directory.Exists(path2))
201 {
202 foreach (FileInfo file in new DirectoryInfo(path2).GetFiles())
203 {
204 this.TryAddReplace(file, TextureReplace.Source.Local, true, false);
205 }
206 }
207 this.RefreshTextures();
208 }
209
210 // Token: 0x0400088D RID: 2189
211 public Dictionary<string, TextureData> texMap = new Dictionary<string, TextureData>();
212}
Definition Msg.cs:7