123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace SceneEditWindow
- {
- [AddComponentMenu("SceneEditWindow/CustomViewItem")]
- [RequireComponent(typeof(UITexture))]
- public class CustomViewItem : MonoBehaviour
- {
- private void Awake()
- {
- this.iconTex = base.GetComponent<UITexture>();
- this.button = base.GetComponentInChildren<UIButton>();
- NDebug.AssertNull(this.button);
- EventDelegate.Add(this.button.onClick, new EventDelegate.Callback(this.OnClickButton));
- this.buttonTweenTarget = this.button.tweenTarget;
- }
- public bool UpdateIcon(Maid maid = null)
- {
- if (maid == null)
- {
- maid = GameMain.Instance.CharacterMgr.GetMaid(0);
- if (maid == null)
- {
- return false;
- }
- }
- if (this.mpn == MPN.chikubi)
- {
- this.mpn = MPN.chikubicolor;
- }
- bool flag = false;
- int num = maid.GetProp(this.mpn).nFileNameRID;
- if (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit && maid.GetProp(this.mpn).nTempFileNameRID != 0)
- {
- num = maid.GetProp(this.mpn).nTempFileNameRID;
- }
- foreach (SceneEdit.SubPropMpnData subPropMpnData in this.sceneEdit.subPropDatas)
- {
- if (this.mpn == subPropMpnData.mpn)
- {
- SubProp subProp = maid.GetSubProp(this.mpn, 0);
- if (subProp != null)
- {
- num = subProp.nFileNameRID;
- }
- }
- }
- bool flag2 = true;
- if ((this.requestNewFace && !this.sceneEdit.isNewFace) || (this.requestFBFace && !this.sceneEdit.isFBFace))
- {
- this.settingRid = 0;
- num = -1;
- flag2 = false;
- }
- if (num != this.settingRid)
- {
- flag = true;
- this.settingRid = num;
- SceneEdit.SMenuItem smenuItem = (!flag2) ? null : this.GetMenuItem(maid, this.mpn);
- if (smenuItem == null || (smenuItem.m_boDelOnly && this.defaultIconTexture != null) || (smenuItem.m_texIconRef == null && this.defaultIconTexture != null))
- {
- this.iconTex.mainTexture = this.defaultIconTexture;
- this.button.tweenTarget = null;
- this.iconTex.color = new Color(1f, 1f, 1f, 0.58f);
- TweenColor component = base.GetComponent<TweenColor>();
- if (component != null)
- {
- component.from = (component.to = this.iconTex.color);
- }
- }
- else if (smenuItem.m_texIconRef)
- {
- this.iconTex.mainTexture = smenuItem.m_texIconRef;
- this.button.tweenTarget = this.buttonTweenTarget;
- this.iconTex.color = Color.white;
- TweenColor component2 = base.GetComponent<TweenColor>();
- if (component2 != null)
- {
- component2.from = (component2.to = this.iconTex.color);
- }
- }
- }
- if (this.mpn == MPN.chikubicolor)
- {
- this.mpn = MPN.chikubi;
- }
- this.button.isEnabled = this.sceneEdit.isEnabledButton(this.mpn);
- if (!this.button.isEnabled)
- {
- this.iconTex.color = this.button.disabledColor;
- }
- else if (!flag)
- {
- SceneEdit.SMenuItem smenuItem2 = (!flag2) ? null : this.GetMenuItem(maid, this.mpn);
- if (smenuItem2 == null || (smenuItem2.m_boDelOnly && this.defaultIconTexture != null) || (smenuItem2.m_texIconRef == null && this.defaultIconTexture != null))
- {
- this.iconTex.color = new Color(1f, 1f, 1f, 0.58f);
- }
- else
- {
- this.iconTex.color = Color.white;
- }
- }
- if ((this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit && this.requestNewFace) || (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit && this.requestFBFace))
- {
- this.button.isEnabled = false;
- this.button.tweenTarget = this.buttonTweenTarget;
- }
- return flag;
- }
- public SceneEdit.SMenuItem GetMenuItem(Maid maid, MPN mpn)
- {
- int num = maid.GetProp(mpn).nFileNameRID;
- if (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit)
- {
- num = maid.GetProp(mpn).nTempFileNameRID;
- }
- foreach (SceneEdit.SubPropMpnData subPropMpnData in this.sceneEdit.subPropDatas)
- {
- if (mpn == subPropMpnData.mpn)
- {
- SubProp subProp = maid.GetSubProp(mpn, 0);
- if (subProp != null)
- {
- num = subProp.nFileNameRID;
- }
- }
- }
- List<SceneEdit.SCategory> categoryList = this.sceneEdit.CategoryList;
- SceneEditInfo.EMenuCategory category = this.GetCategory(mpn);
- bool flag = false;
- switch (mpn)
- {
- case MPN.chikubicolor:
- mpn = MPN.chikubi;
- flag = true;
- break;
- case MPN.eyewhite:
- mpn = MPN.folder_eyewhite;
- flag = true;
- break;
- default:
- switch (mpn)
- {
- case MPN.skin:
- mpn = MPN.folder_skin;
- flag = true;
- break;
- case MPN.underhair:
- mpn = MPN.folder_underhair;
- flag = true;
- break;
- case MPN.mayu:
- mpn = MPN.folder_mayu;
- flag = true;
- break;
- case MPN.eye:
- mpn = MPN.folder_eye;
- flag = true;
- break;
- }
- break;
- case MPN.matsuge_up:
- mpn = MPN.folder_matsuge_up;
- flag = true;
- break;
- case MPN.matsuge_low:
- mpn = MPN.folder_matsuge_low;
- flag = true;
- break;
- case MPN.futae:
- mpn = MPN.folder_futae;
- flag = true;
- break;
- }
- for (int j = 0; j < categoryList.Count; j++)
- {
- if (categoryList[j].m_eCategory == category)
- {
- for (int k = 0; k < categoryList[j].m_listPartsType.Count; k++)
- {
- if (categoryList[j].m_listPartsType[k].m_mpn == mpn)
- {
- for (int l = 0; l < categoryList[j].m_listPartsType[k].m_listMenu.Count; l++)
- {
- SceneEdit.SMenuItem smenuItem = categoryList[j].m_listPartsType[k].m_listMenu[l];
- if (smenuItem.m_nMenuFileRID == num)
- {
- return smenuItem;
- }
- if (flag)
- {
- foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
- {
- if (smenuItem2.m_nMenuFileRID == num)
- {
- return smenuItem;
- }
- }
- }
- }
- }
- }
- }
- }
- return null;
- }
- public void OnClickButton()
- {
- this.sceneEdit.ClickEmulate(this.mpn, false);
- }
- private SceneEditInfo.EMenuCategory GetCategory(MPN mpn)
- {
- Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
- if (!dicPartsTypePair.ContainsKey(mpn))
- {
- return SceneEditInfo.EMenuCategory.プロフィ\u30FCル;
- }
- return dicPartsTypePair[mpn].m_eMenuCate;
- }
- [SerializeField]
- public MPN mpn;
- [SerializeField]
- public SceneEdit sceneEdit;
- [NonSerialized]
- public Texture2D defaultIconTexture;
- [NonSerialized]
- public bool requestNewFace;
- [NonSerialized]
- public bool requestFBFace;
- private UIButton button;
- private GameObject buttonTweenTarget;
- private UITexture iconTex;
- private int settingRid;
- }
- }
|