22 public DirectoryInfo dir
46 return this.am.partialMap;
51 public static void Activate()
55 PartialMapMenu.Instance = Util.Instantiate<
PartialMapMenu>(
"UI/BuildMenu/PartialMapMenu",
EMono.ui);
65 this.rootDir =
new DirectoryInfo(CorePath.MapPieceSaveUser);
66 this.goCat.SetActive(this.IsEditor);
67 this.RefreshOptions();
70 this.RefreshCategory(
null);
73 this.listCat.Select<DirectoryInfo>((DirectoryInfo a) => a.FullName ==
PartialMapMenu.lastDir.FullName,
false);
79 this.listCatSub.Select<DirectoryInfo>((DirectoryInfo a) => a.FullName ==
PartialMapMenu.lastDirSub.FullName,
false);
86 public void Deactivate()
88 this.DestorySprites();
89 UnityEngine.Object.DestroyImmediate(
PartialMapMenu.Instance.gameObject);
93 public void SetVisible(
bool visible)
95 this.RefreshOptions();
96 this.goMain.SetActive(visible);
100 public void DestorySprites()
102 foreach (Sprite sprite
in this.dictSprite.Values)
104 UnityEngine.Object.Destroy(sprite.texture);
105 UnityEngine.Object.Destroy(sprite);
107 this.dictSprite.Clear();
111 public void RefreshOptions()
113 this.goOption.SetActive(this.IsEditor && this.partial !=
null);
114 if (this.partial ==
null)
118 this.toggleRotate.SetToggle(this.partial.allowRotate, delegate(
bool on)
120 this.partial.allowRotate = on;
121 this.partial.Update();
123 this.toggleIgnoreBlock.SetToggle(this.partial.ignoreBlock, delegate(
bool on)
125 this.partial.ignoreBlock = on;
126 this.partial.Update();
131 public void Refresh()
138 this.am.Import(a.path);
139 this.am.partialMap.name = a.name;
143 string path = a.path.GetFullFileNameWithoutExtension() +
".txt";
144 if (File.Exists(path))
146 string text = File.ReadAllText(path);
152 if (a.name.IsEmpty())
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);
161 string path2 = a.path.GetFullFileNameWithoutExtension() +
".jpg";
162 if (File.Exists(path2))
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;
174 b.icon.sprite = sprite;
176 UIButton componentInDirectChildren = b.GetComponentInDirectChildren<UIButton>();
177 componentInDirectChildren.SetActive(this.IsEditor);
178 componentInDirectChildren.SetOnClick(delegate
181 this.am.overwritePath = a.path;
182 this.am.RefreshMenu(
false);
185 onList = delegate(UIList.SortMode m)
187 foreach (FileInfo fileInfo
in this.dir.GetFiles().Concat(MOD.listPartialMaps))
189 if (fileInfo.Name.EndsWith(
".mp"))
192 if (metaData !=
null && metaData.partial !=
null)
194 this.list.Add(metaData);
204 public void RefreshCategory(DirectoryInfo dir =
null)
206 UIList _listCat = this.listCat;
212 if (dir.FullName !=
this.rootDir.FullName)
214 _listCat = this.listCatSub;
218 _listCat.callbacks =
new UIList.Callback<DirectoryInfo, UIButton>
220 onClick = delegate(DirectoryInfo a, UIButton b)
223 _listCat.Select(a,
false);
227 PartialMapMenu.lastDirSub = a;
228 PartialMapMenu.lastDir = a;
229 this.RefreshCategory(a);
233 PartialMapMenu.lastDirSub = a;
237 onInstantiate = delegate(DirectoryInfo a, UIButton b)
240 foreach (FileInfo fileInfo
in a.GetFiles(
"*.mp", SearchOption.AllDirectories))
244 b.mainText.text = ((a == dir && !isMain) ?
"(Root)" : (a.Name +
"(" + num.ToString() +
")"));
246 onList = delegate(UIList.SortMode m)
248 _listCat.Add(isMain ? this.rootDir : dir);
249 foreach (DirectoryInfo o
in isMain ?
new DirectoryInfo(CorePath.MapPieceSave).GetDirectories() : dir.GetDirectories())
255 _listCat.List(
false);
256 this.listCatSub.SetActive(this.listCatSub.items.Count > 1);
260 public void OpenFolder()
262 Util.ShowExplorer(CorePath.MapPieceSave +
"Test",
false);
269 public static DirectoryInfo lastDir;
272 public static DirectoryInfo lastDirSub;
275 public GameObject goMain;
278 public GameObject goCat;
281 public GameObject goOption;
284 public UIList listCat;
287 public UIList listCatSub;
290 public UIDynamicList list;
293 public CanvasGroup cg;
296 public UIButton buttonSave;
299 public UIButton buttonEdit;
302 public UIButton buttonDelete;
305 public UIButton toggleRotate;
308 public UIButton toggleIgnoreBlock;
311 public Dictionary<string, Sprite> dictSprite =
new Dictionary<string, Sprite>();
314 public DirectoryInfo rootDir;