123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- namespace SceneEditWindow
- {
- [AddComponentMenu("SceneEditWindow/CustomViewWindow")]
- public class CustomViewWindow : BasePhotoWindow
- {
- public List<CustomViewItem> itemList { get; private set; }
- public override string windowName
- {
- get
- {
- return "CustomViewWindow";
- }
- }
- public override void Awake()
- {
- base.Awake();
- CustomViewItemData.Create();
- UIWFTabButton[] componentsInChildren = this.tabPanel.GetComponentsInChildren<UIWFTabButton>();
- foreach (UIWFTabButton uiwftabButton in componentsInChildren)
- {
- EventDelegate.Add(uiwftabButton.onSelect, new EventDelegate.Callback(this.OnClickSelectCategory));
- }
- this.tabPanel.UpdateChildren();
- }
- private void OnDestroy()
- {
- foreach (KeyValuePair<string, Texture2D> keyValuePair in this.texDic)
- {
- UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
- }
- this.texDic.Clear();
- }
- public void Create()
- {
- if (this.itemList != null)
- {
- return;
- }
- this.itemList = new List<CustomViewItem>();
- HashSet<MPN> hashSet = new HashSet<MPN>();
- foreach (SceneEdit.SCategory scategory in this.sceneEdit.CategoryList)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- hashSet.Add(spartsType.m_mpn);
- foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
- {
- hashSet.Add(smenuItem.m_mpn);
- if (smenuItem.m_eColorSetMPN != MPN.null_mpn)
- {
- hashSet.Add(smenuItem.m_eColorSetMPN);
- }
- }
- }
- }
- foreach (CustomViewItemData.ItemData itemData in CustomViewItemData.itemList)
- {
- if (hashSet.Contains(itemData.mpn) && (!itemData.requestNewFace || PluginData.IsEnabled("GP001")))
- {
- if (!this.texDic.ContainsKey(itemData.iconTexName))
- {
- this.texDic.Add(itemData.iconTexName, ImportCM.CreateTexture(itemData.iconTexName));
- }
- CustomViewItem componentInChildren = Utility.CreatePrefab(this.pageItemGrits[itemData.page].gameObject, "SceneEdit/WindowParts/CustomItem", true).GetComponentInChildren<CustomViewItem>();
- componentInChildren.sceneEdit = this.sceneEdit;
- componentInChildren.mpn = itemData.mpn;
- componentInChildren.requestNewFace = itemData.requestNewFace;
- componentInChildren.defaultIconTexture = this.texDic[itemData.iconTexName];
- componentInChildren.GetComponentInChildren<UIWidget>().depth = 15;
- this.itemList.Add(componentInChildren);
- }
- }
- foreach (UIGrid grid in this.pageItemGrits)
- {
- Utility.ResetNGUI(grid);
- }
- this.UpdateAllItem();
- this.tabPanel.Select(this.tabPanel.GetComponentInChildren<UIWFTabButton>());
- this.UpdateChildren();
- }
- public bool UpdateAllItem()
- {
- bool flag = false;
- foreach (CustomViewItem customViewItem in this.itemList)
- {
- flag |= customViewItem.UpdateIcon(null);
- }
- return flag;
- }
- private void OnClickSelectCategory()
- {
- if (!UIWFSelectButton.selected)
- {
- return;
- }
- UIWFTabButton[] componentsInChildren = this.tabPanel.GetComponentsInChildren<UIWFTabButton>();
- for (int i = 0; i < componentsInChildren.Length; i++)
- {
- if (componentsInChildren[i] == UIWFSelectButton.current)
- {
- for (int j = 0; j < this.pageItemGrits.Length; j++)
- {
- this.pageItemGrits[j].transform.localScale = ((j != i) ? Vector3.zero : Vector3.one);
- }
- break;
- }
- }
- }
- [SerializeField]
- public SceneEdit sceneEdit;
- [SerializeField]
- private UIWFTabPanel tabPanel;
- [SerializeField]
- private UIGrid[] pageItemGrits;
- private Dictionary<string, Texture2D> texDic = new Dictionary<string, Texture2D>();
- }
- }
|