Elin Modding Docs Doc
Loading...
Searching...
No Matches
PartialMapMenu.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using UnityEngine;
6
7// Token: 0x020004FA RID: 1274
8public class PartialMapMenu : EMono
9{
10 // Token: 0x17000AEF RID: 2799
11 // (get) Token: 0x060021F7 RID: 8695 RVA: 0x000BC468 File Offset: 0x000BA668
12 public AM_Copy am
13 {
14 get
15 {
16 return ActionMode.Copy;
17 }
18 }
19
20 // Token: 0x17000AF0 RID: 2800
21 // (get) Token: 0x060021F8 RID: 8696 RVA: 0x000BC46F File Offset: 0x000BA66F
22 public DirectoryInfo dir
23 {
24 get
25 {
26 return this.am.dir;
27 }
28 }
29
30 // Token: 0x17000AF1 RID: 2801
31 // (get) Token: 0x060021F9 RID: 8697 RVA: 0x000BC47C File Offset: 0x000BA67C
32 public bool IsEditor
33 {
34 get
35 {
36 return MapPiece.IsEditor;
37 }
38 }
39
40 // Token: 0x17000AF2 RID: 2802
41 // (get) Token: 0x060021FA RID: 8698 RVA: 0x000BC483 File Offset: 0x000BA683
42 public PartialMap partial
43 {
44 get
45 {
46 return this.am.partialMap;
47 }
48 }
49
50 // Token: 0x060021FB RID: 8699 RVA: 0x000BC490 File Offset: 0x000BA690
51 public static void Activate()
52 {
53 if (!PartialMapMenu.Instance)
54 {
55 PartialMapMenu.Instance = Util.Instantiate<PartialMapMenu>("UI/BuildMenu/PartialMapMenu", EMono.ui);
56 PartialMapMenu.Instance.Init();
57 }
58 PartialMapMenu.Instance.Refresh();
59 MapPiece.CacheMap.Clear();
60 }
61
62 // Token: 0x060021FC RID: 8700 RVA: 0x000BC4D0 File Offset: 0x000BA6D0
63 public void Init()
64 {
65 this.rootDir = new DirectoryInfo(CorePath.MapPieceSaveUser);
66 this.goCat.SetActive(this.IsEditor);
67 this.RefreshOptions();
68 if (this.IsEditor)
69 {
70 this.RefreshCategory(null);
71 if (PartialMapMenu.lastDir != null)
72 {
73 this.listCat.Select<DirectoryInfo>((DirectoryInfo a) => a.FullName == PartialMapMenu.lastDir.FullName, false);
74 this.am.dir = PartialMapMenu.lastDir;
75 }
76 if (PartialMapMenu.lastDirSub != null)
77 {
78 this.RefreshCategory(PartialMapMenu.lastDir);
79 this.listCatSub.Select<DirectoryInfo>((DirectoryInfo a) => a.FullName == PartialMapMenu.lastDirSub.FullName, false);
80 this.am.dir = PartialMapMenu.lastDirSub;
81 }
82 }
83 }
84
85 // Token: 0x060021FD RID: 8701 RVA: 0x000BC5A5 File Offset: 0x000BA7A5
86 public void Deactivate()
87 {
88 this.DestorySprites();
89 UnityEngine.Object.DestroyImmediate(PartialMapMenu.Instance.gameObject);
90 }
91
92 // Token: 0x060021FE RID: 8702 RVA: 0x000BC5BC File Offset: 0x000BA7BC
93 public void SetVisible(bool visible)
94 {
95 this.RefreshOptions();
96 this.goMain.SetActive(visible);
97 }
98
99 // Token: 0x060021FF RID: 8703 RVA: 0x000BC5D0 File Offset: 0x000BA7D0
100 public void DestorySprites()
101 {
102 foreach (Sprite sprite in this.dictSprite.Values)
103 {
104 UnityEngine.Object.Destroy(sprite.texture);
105 UnityEngine.Object.Destroy(sprite);
106 }
107 this.dictSprite.Clear();
108 }
109
110 // Token: 0x06002200 RID: 8704 RVA: 0x000BC63C File Offset: 0x000BA83C
111 public void RefreshOptions()
112 {
113 this.goOption.SetActive(this.IsEditor && this.partial != null);
114 if (this.partial == null)
115 {
116 return;
117 }
118 this.toggleRotate.SetToggle(this.partial.allowRotate, delegate(bool on)
119 {
120 this.partial.allowRotate = on;
121 this.partial.Update();
122 });
123 this.toggleIgnoreBlock.SetToggle(this.partial.ignoreBlock, delegate(bool on)
124 {
125 this.partial.ignoreBlock = on;
126 this.partial.Update();
127 });
128 }
129
130 // Token: 0x06002201 RID: 8705 RVA: 0x000BC6B8 File Offset: 0x000BA8B8
131 public void Refresh()
132 {
133 this.list.callbacks = new UIList.Callback<MapMetaData, ButtonGrid>
134 {
135 onClick = delegate(MapMetaData a, ButtonGrid b)
136 {
137 SE.Click();
138 this.am.Import(a.path);
139 this.am.partialMap.name = a.name;
140 },
141 onRedraw = delegate(MapMetaData a, ButtonGrid b, int i)
142 {
143 string path = a.path.GetFullFileNameWithoutExtension() + ".txt";
144 if (File.Exists(path))
145 {
146 string text = File.ReadAllText(path);
147 if (!text.IsEmpty())
148 {
149 a.name = text;
150 }
151 }
152 if (a.name.IsEmpty())
153 {
154 a.name = "unknown";
155 }
156 b.mainText.SetText(this.IsEditor ? new FileInfo(a.path).Name : a.name);
157 b.subText.text = Lang._currency(a.partial.value, false, 14);
158 Sprite sprite = this.dictSprite.TryGetValue(a.path, null);
159 if (!sprite)
160 {
161 string path2 = a.path.GetFullFileNameWithoutExtension() + ".jpg";
162 if (File.Exists(path2))
163 {
164 Texture2D texture2D = new Texture2D(1, 1);
165 byte[] source = File.ReadAllBytes(path2);
166 texture2D.LoadImage(source.ToArray<byte>());
167 sprite = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), new Vector2(0.5f, 0.5f));
168 b.icon.sprite = sprite;
169 this.dictSprite[a.path] = sprite;
170 }
171 }
172 if (sprite)
173 {
174 b.icon.sprite = sprite;
175 }
176 UIButton componentInDirectChildren = b.GetComponentInDirectChildren<UIButton>();
177 componentInDirectChildren.SetActive(this.IsEditor);
178 componentInDirectChildren.SetOnClick(delegate
179 {
180 SE.Click();
181 this.am.overwritePath = a.path;
182 this.am.RefreshMenu(false);
183 });
184 },
185 onList = delegate(UIList.SortMode m)
186 {
187 foreach (FileInfo fileInfo in this.dir.GetFiles().Concat(MOD.listPartialMaps))
188 {
189 if (fileInfo.Name.EndsWith(".mp"))
190 {
191 MapMetaData metaData = Map.GetMetaData(fileInfo.FullName);
192 if (metaData != null && metaData.partial != null)
193 {
194 this.list.Add(metaData);
195 }
196 }
197 }
198 }
199 };
200 this.list.List();
201 }
202
203 // Token: 0x06002202 RID: 8706 RVA: 0x000BC718 File Offset: 0x000BA918
204 public void RefreshCategory(DirectoryInfo dir = null)
205 {
206 UIList _listCat = this.listCat;
207 bool isMain = true;
208 if (dir == null)
209 {
210 dir = this.rootDir;
211 }
212 if (dir.FullName != this.rootDir.FullName)
213 {
214 _listCat = this.listCatSub;
215 isMain = false;
216 }
217 _listCat.Clear();
218 _listCat.callbacks = new UIList.Callback<DirectoryInfo, UIButton>
219 {
220 onClick = delegate(DirectoryInfo a, UIButton b)
221 {
222 SE.Click();
223 _listCat.Select(a, false);
224 this.am.dir = a;
225 if (isMain)
226 {
227 PartialMapMenu.lastDirSub = a;
228 PartialMapMenu.lastDir = a;
229 this.RefreshCategory(a);
230 }
231 else
232 {
233 PartialMapMenu.lastDirSub = a;
234 }
235 this.Refresh();
236 },
237 onInstantiate = delegate(DirectoryInfo a, UIButton b)
238 {
239 int num = 0;
240 foreach (FileInfo fileInfo in a.GetFiles("*.mp", SearchOption.AllDirectories))
241 {
242 num++;
243 }
244 b.mainText.text = ((a == dir && !isMain) ? "(Root)" : (a.Name + "(" + num.ToString() + ")"));
245 },
246 onList = delegate(UIList.SortMode m)
247 {
248 _listCat.Add(isMain ? this.rootDir : dir);
249 foreach (DirectoryInfo o in isMain ? new DirectoryInfo(CorePath.MapPieceSave).GetDirectories() : dir.GetDirectories())
250 {
251 _listCat.Add(o);
252 }
253 }
254 };
255 _listCat.List(false);
256 this.listCatSub.SetActive(this.listCatSub.items.Count > 1);
257 }
258
259 // Token: 0x06002203 RID: 8707 RVA: 0x000BC80B File Offset: 0x000BAA0B
260 public void OpenFolder()
261 {
262 Util.ShowExplorer(CorePath.MapPieceSave + "Test", false);
263 }
264
265 // Token: 0x04001186 RID: 4486
266 public static PartialMapMenu Instance;
267
268 // Token: 0x04001187 RID: 4487
269 public static DirectoryInfo lastDir;
270
271 // Token: 0x04001188 RID: 4488
272 public static DirectoryInfo lastDirSub;
273
274 // Token: 0x04001189 RID: 4489
275 public GameObject goMain;
276
277 // Token: 0x0400118A RID: 4490
278 public GameObject goCat;
279
280 // Token: 0x0400118B RID: 4491
281 public GameObject goOption;
282
283 // Token: 0x0400118C RID: 4492
284 public UIList listCat;
285
286 // Token: 0x0400118D RID: 4493
287 public UIList listCatSub;
288
289 // Token: 0x0400118E RID: 4494
290 public UIDynamicList list;
291
292 // Token: 0x0400118F RID: 4495
293 public CanvasGroup cg;
294
295 // Token: 0x04001190 RID: 4496
296 public UIButton buttonSave;
297
298 // Token: 0x04001191 RID: 4497
299 public UIButton buttonEdit;
300
301 // Token: 0x04001192 RID: 4498
302 public UIButton buttonDelete;
303
304 // Token: 0x04001193 RID: 4499
305 public UIButton toggleRotate;
306
307 // Token: 0x04001194 RID: 4500
308 public UIButton toggleIgnoreBlock;
309
310 // Token: 0x04001195 RID: 4501
311 public Dictionary<string, Sprite> dictSprite = new Dictionary<string, Sprite>();
312
313 // Token: 0x04001196 RID: 4502
314 public DirectoryInfo rootDir;
315}
Definition EMono.cs:6
Definition Map.cs:15