123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- namespace SceneEditWindow
- {
- [AddComponentMenu("SceneEditWindow/BgIconWindow")]
- public class BgIconWindow : BaseIconWindow
- {
- public int selectedIconId { get; private set; }
- public override string windowName
- {
- get
- {
- return "BgIconWindow";
- }
- }
- public override void Awake()
- {
- BgIconData.Create();
- base.Awake();
- }
- protected virtual void OnDestroy()
- {
- foreach (KeyValuePair<int, Texture> keyValuePair in this.texDic)
- {
- UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
- }
- this.texDic.Clear();
- }
- public void Exec(int bgId)
- {
- if (!this.tabButtonDic.ContainsKey(bgId))
- {
- Debug.LogError("背景番号[" + bgId.ToString() + "]の背景が見つかりませんでした");
- return;
- }
- this.tabPanel.Select(this.tabButtonDic[bgId]);
- }
- public void NextBG()
- {
- if (this.createItemList.Count <= 1)
- {
- return;
- }
- int num = int.MinValue;
- for (int i = 0; i < this.createItemList.Count; i++)
- {
- if (this.createItemList[i].id == this.selectedIconId)
- {
- num = this.createItemList[0].id;
- if (i + 1 < this.createItemList.Count)
- {
- num = this.createItemList[i + 1].id;
- }
- break;
- }
- }
- if (num != -2147483648)
- {
- this.Exec(num);
- }
- }
- public void PrevBG()
- {
- if (this.createItemList.Count <= 1)
- {
- return;
- }
- int num = int.MinValue;
- for (int i = 0; i < this.createItemList.Count; i++)
- {
- if (this.createItemList[i].id == this.selectedIconId)
- {
- num = this.createItemList[this.createItemList.Count - 1].id;
- if (0 <= i - 1)
- {
- num = this.createItemList[i - 1].id;
- }
- break;
- }
- }
- if (num != -2147483648)
- {
- this.Exec(num);
- }
- }
- protected override void OnSelectItem(int selectItemId)
- {
- BgIconData.ItemData itemData = BgIconData.GetItemData(selectItemId);
- this.selectedIconId = itemData.id;
- if (this.onSelectBgEvent != null)
- {
- this.onSelectBgEvent(itemData);
- }
- }
- protected override UIWFTabButton CreateItemObject(GameObject parent, int createItemId)
- {
- GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true);
- if (!this.texDic.ContainsKey(createItemId))
- {
- this.texDic.Add(createItemId, ImportCM.CreateTexture(BgIconData.GetItemData(createItemId).iconTexName));
- }
- UITexture component = gameObject.GetComponent<UITexture>();
- component.mainTexture = this.texDic[createItemId];
- this.createItemList.Add(BgIconData.GetItemData(createItemId));
- return gameObject.GetComponent<UIWFTabButton>();
- }
- protected override List<int> CreateItemIdList()
- {
- List<int> list = new List<int>();
- foreach (BgIconData.ItemData itemData in BgIconData.itemList)
- {
- if (!SceneEdit.compatibilityMode || itemData.isLegacyBG)
- {
- if (SceneEdit.compatibilityMode || !itemData.isLegacyBG)
- {
- if (itemData.enabled)
- {
- list.Add(itemData.id);
- }
- }
- }
- }
- return list;
- }
- public Action<BgIconData.ItemData> onSelectBgEvent;
- private Dictionary<int, Texture> texDic = new Dictionary<int, Texture>();
- private List<BgIconData.ItemData> createItemList = new List<BgIconData.ItemData>();
- }
- }
|