123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using I2.Loc;
- using Kasizuki;
- using UnityEngine;
- public class PhotoFaceDataShortcutSetter : MonoBehaviour
- {
- public float fadeSpeed
- {
- get
- {
- return this.m_FadeSpeed;
- }
- set
- {
- this.m_FadeSpeed = Mathf.Clamp(value, 0.001f, 1f);
- }
- }
- private PhotoFaceDataShortcut targetControllerRight { get; set; }
- private PhotoFaceDataShortcut targetControllerLeft { get; set; }
- private PhotoFaceDataShortcut.ItemData nowSelectItem
- {
- get
- {
- return this.m_NowSelectItem;
- }
- set
- {
- this.m_NowSelectItem = value;
- }
- }
- public void Init(PhotoFaceDataShortcut rightHandUI, PhotoFaceDataShortcut LeftHandUI)
- {
- this.m_FadeWindowShortcutButtonsRight = this.m_ButtonListShortcutRight.GetComponent<NGUIWindow>();
- this.m_FadeWindowShortcutButtonsLeft = this.m_ButtonListShortcutLeft.GetComponent<NGUIWindow>();
- this.m_FadeWindowFaceDataList = this.m_WindowListFaceData.GetComponent<NGUIWindow>();
- this.targetControllerRight = rightHandUI;
- this.targetControllerLeft = LeftHandUI;
- PhotoFaceData.Create();
- List<PhotoFaceData> data2 = PhotoFaceData.data;
- ListViewerWindow windowListFaceData = this.m_WindowListFaceData;
- windowListFaceData.Show<PhotoFaceData, UIWFTabButton>(data2, delegate(int index, PhotoFaceData data, UIWFTabButton item)
- {
- UILabel componentInChildren = item.GetComponentInChildren<UILabel>();
- componentInChildren.text = data.name;
- componentInChildren.GetComponent<Localize>().SetTerm(data.termName);
- EventDelegate.Add(item.onClick, delegate()
- {
- this.OnClickData(data);
- });
- });
- UIWFTabPanel component = windowListFaceData.viewer.parentItemArea.GetComponent<UIWFTabPanel>();
- if (component)
- {
- component.UpdateChildren();
- }
- this.m_ButtonListShortcutRight.Show<Transform>(this.targetControllerRight.itemDataList.Count, delegate(int index, Transform trans)
- {
- PhotoFaceDataShortcut.ItemData data = this.targetControllerRight.itemDataList[index];
- UILabel componentInChildren = trans.GetComponentInChildren<UILabel>();
- UIButton componentInChildren2 = trans.GetComponentInChildren<UIButton>();
- Localize componentInChildren3 = trans.GetComponentInChildren<Localize>();
- componentInChildren.text = data.GetDataName();
- componentInChildren3.SetTerm(data.GetDataTermName());
- EventDelegate.Add(componentInChildren2.onClick, delegate()
- {
- this.OnClickShortcutButton(data);
- });
- PhotoFaceDataShortcutSetter.ItemData itemData = trans.gameObject.AddComponent<PhotoFaceDataShortcutSetter.ItemData>();
- itemData.label = componentInChildren;
- itemData.localize = componentInChildren3;
- this.m_ItemPairDic.Add(data, itemData);
- });
- this.m_ButtonListShortcutLeft.Show<Transform>(this.targetControllerLeft.itemDataList.Count, delegate(int index, Transform trans)
- {
- PhotoFaceDataShortcut.ItemData data = this.targetControllerLeft.itemDataList[index];
- UILabel componentInChildren = trans.GetComponentInChildren<UILabel>();
- UIButton componentInChildren2 = trans.GetComponentInChildren<UIButton>();
- Localize componentInChildren3 = trans.GetComponentInChildren<Localize>();
- componentInChildren.text = data.GetDataName();
- componentInChildren3.SetTerm(data.GetDataTermName());
- EventDelegate.Add(componentInChildren2.onClick, delegate()
- {
- this.OnClickShortcutButton(data);
- });
- PhotoFaceDataShortcutSetter.ItemData itemData = trans.gameObject.AddComponent<PhotoFaceDataShortcutSetter.ItemData>();
- itemData.label = componentInChildren;
- itemData.localize = componentInChildren3;
- this.m_ItemPairDic.Add(data, itemData);
- });
- Transform transform = this.m_ParentAddFaceOptions.transform.Find("Buttons");
- for (int i = 0; i < transform.childCount; i++)
- {
- WFCheckBox component2 = transform.GetChild(i).GetComponent<WFCheckBox>();
- component2.check = false;
- component2.enabled = true;
- this.m_AddFaceOptionDic.Add(component2.GetComponentInChildren<UILabel>().text, component2);
- component2.onClick.Add(new Action<WFCheckBox>(this.OnClickCheckBoxAddOption));
- }
- EventDelegate.Add(this.m_ButtonFaceListOK.onClick, new EventDelegate.Callback(this.OnClickFaceListOK));
- NGUIWindow fadeWindowFaceDataList = this.m_FadeWindowFaceDataList;
- fadeWindowFaceDataList.OnOpen = (Action)Delegate.Combine(fadeWindowFaceDataList.OnOpen, new Action(delegate()
- {
- this.m_WindowListFaceData.Reposition();
- }));
- }
- private void OnClickData(PhotoFaceData data)
- {
- TMorph.AddBlendType blendType = this.ConvertBlendType();
- this.ApplyItemData(this.nowSelectItem, data, blendType);
- PhotoFaceDataShortcutSetter.ItemData itemData;
- if (this.m_ItemPairDic != null && this.m_ItemPairDic.TryGetValue(this.nowSelectItem, out itemData))
- {
- itemData.label.text = this.nowSelectItem.GetDataName();
- itemData.localize.SetTerm(this.nowSelectItem.GetDataTermName());
- }
- if (this.nowSelectItem != null)
- {
- if (this.targetControllerRight.itemDataList.Contains(this.nowSelectItem))
- {
- this.targetControllerRight.Emulate(this.nowSelectItem);
- }
- else if (this.targetControllerLeft.itemDataList.Contains(this.nowSelectItem))
- {
- this.targetControllerLeft.Emulate(this.nowSelectItem);
- }
- else
- {
- Debug.LogWarning("コントローラに存在しない項目を更新しているかも");
- }
- }
- }
- private void OnClickShortcutButton(PhotoFaceDataShortcut.ItemData item)
- {
- this.nowSelectItem = item;
- this.m_FadeWindowShortcutButtonsRight.Close(this.fadeSpeed, null);
- this.m_FadeWindowShortcutButtonsLeft.Close(this.fadeSpeed, null);
- this.WaitTime(this.fadeSpeed, delegate
- {
- this.m_FadeWindowFaceDataList.Open(this.fadeSpeed, null);
- });
- UIWFTabPanel component = this.m_WindowListFaceData.viewer.parentItemArea.GetComponent<UIWFTabPanel>();
- UIWFTabButton selectButtonObject = component.GetSelectButtonObject();
- if (selectButtonObject != null)
- {
- selectButtonObject.SetSelect(false);
- }
- component.ResetSelect();
- component.UpdateChildren();
- this.UpdateCheckBoxAddOption(item);
- }
- private void OnClickFaceListOK()
- {
- this.m_FadeWindowFaceDataList.Close(this.fadeSpeed, null);
- this.WaitTime(this.fadeSpeed, delegate
- {
- this.m_FadeWindowShortcutButtonsRight.Open(this.fadeSpeed, null);
- this.m_FadeWindowShortcutButtonsLeft.Open(this.fadeSpeed, null);
- });
- ControllerShortcutSettingData.config.Write();
- }
- private void ApplyItemData(PhotoFaceDataShortcut.ItemData itemData, PhotoFaceData data, TMorph.AddBlendType blendType)
- {
- if (itemData == null)
- {
- Debug.Log("コントローラの項目の参照がありませんでした");
- return;
- }
- if (data == null)
- {
- Debug.Log("表情データがnullらしい");
- }
- itemData.data = data;
- itemData.blendType = blendType;
- itemData.isOpenMouth = this.IsOpenMouth();
- }
- private TMorph.AddBlendType ConvertBlendType()
- {
- TMorph.AddBlendType addBlendType = TMorph.AddBlendType.None;
- Dictionary<string, TMorph.AddBlendType> dictionary = new Dictionary<string, TMorph.AddBlendType>
- {
- {
- "頬染め1",
- TMorph.AddBlendType.Cheek1
- },
- {
- "頬染め2",
- TMorph.AddBlendType.Cheek2
- },
- {
- "頬染め3",
- TMorph.AddBlendType.Cheek3
- },
- {
- "涙1",
- TMorph.AddBlendType.Tear1
- },
- {
- "涙2",
- TMorph.AddBlendType.Tear2
- },
- {
- "涙3",
- TMorph.AddBlendType.Tear3
- },
- {
- "涙(玉)",
- TMorph.AddBlendType.TearBig
- },
- {
- "涎",
- TMorph.AddBlendType.Yodare
- },
- {
- "赤面",
- TMorph.AddBlendType.Blush
- },
- {
- "ショック",
- TMorph.AddBlendType.Shock
- }
- };
- foreach (KeyValuePair<string, TMorph.AddBlendType> keyValuePair in dictionary)
- {
- if (this.m_AddFaceOptionDic.ContainsKey(keyValuePair.Key) && this.m_AddFaceOptionDic[keyValuePair.Key].check)
- {
- addBlendType |= keyValuePair.Value;
- }
- }
- return addBlendType;
- }
- private bool IsOpenMouth()
- {
- return this.m_AddFaceOptionDic["口を開く"].check;
- }
- private void UpdateCheckBoxAddOption(PhotoFaceDataShortcut.ItemData itemData)
- {
- if (itemData == null || itemData.data == null)
- {
- Debug.Log("表情データが空だったので、追加表情データの表示は最後の状態を引き継ぐ");
- return;
- }
- Dictionary<string, TMorph.AddBlendType> dictionary = new Dictionary<string, TMorph.AddBlendType>
- {
- {
- "頬染め1",
- TMorph.AddBlendType.Cheek1
- },
- {
- "頬染め2",
- TMorph.AddBlendType.Cheek2
- },
- {
- "頬染め3",
- TMorph.AddBlendType.Cheek3
- },
- {
- "涙1",
- TMorph.AddBlendType.Tear1
- },
- {
- "涙2",
- TMorph.AddBlendType.Tear2
- },
- {
- "涙3",
- TMorph.AddBlendType.Tear3
- },
- {
- "涙(玉)",
- TMorph.AddBlendType.TearBig
- },
- {
- "涎",
- TMorph.AddBlendType.Yodare
- },
- {
- "赤面",
- TMorph.AddBlendType.Blush
- },
- {
- "ショック",
- TMorph.AddBlendType.Shock
- }
- };
- foreach (KeyValuePair<string, TMorph.AddBlendType> keyValuePair in dictionary)
- {
- this.m_AddFaceOptionDic[keyValuePair.Key].check = ((itemData.blendType & keyValuePair.Value) != TMorph.AddBlendType.None);
- }
- }
- private void OnClickCheckBoxAddOption(WFCheckBox check_box)
- {
- string[] array = new string[]
- {
- "頬染め1",
- "頬染め2",
- "頬染め3"
- };
- string[] array2 = new string[]
- {
- "涙1",
- "涙2",
- "涙3"
- };
- string[][] array3 = new string[][]
- {
- array,
- array2
- };
- foreach (KeyValuePair<string, WFCheckBox> keyValuePair in this.m_AddFaceOptionDic)
- {
- if (keyValuePair.Value == check_box)
- {
- foreach (string[] array4 in array3)
- {
- if (0 <= Array.IndexOf<string>(array4, keyValuePair.Key))
- {
- for (int j = 0; j < array4.Length; j++)
- {
- if (!(array4[j] == keyValuePair.Key))
- {
- if (this.m_AddFaceOptionDic[array4[j]].check)
- {
- this.m_AddFaceOptionDic[array4[j]].check = false;
- }
- }
- }
- }
- }
- }
- }
- if (this.nowSelectItem != null && this.nowSelectItem.data != null)
- {
- this.ApplyItemData(this.nowSelectItem, this.nowSelectItem.data, this.ConvertBlendType());
- if (this.nowSelectItem != null)
- {
- if (this.targetControllerRight.itemDataList.Contains(this.nowSelectItem))
- {
- this.targetControllerRight.Emulate(this.nowSelectItem);
- }
- else if (this.targetControllerLeft.itemDataList.Contains(this.nowSelectItem))
- {
- this.targetControllerLeft.Emulate(this.nowSelectItem);
- }
- else
- {
- Debug.LogWarning("コントローラに存在しない項目を更新しているかもしれない");
- }
- }
- }
- }
- private void WaitTime(float time, Action onFinish)
- {
- base.StartCoroutine(this.CoWaitTime(time, onFinish));
- }
- private IEnumerator CoWaitTime(float time, Action onFinish)
- {
- yield return new WaitForSeconds(time);
- if (onFinish != null)
- {
- onFinish();
- }
- yield break;
- }
- [SerializeField]
- [Range(0.001f, 1f)]
- private float m_FadeSpeed = 0.25f;
- [SerializeField]
- private CircleCommandUI m_ButtonListShortcutRight;
- [SerializeField]
- private CircleCommandUI m_ButtonListShortcutLeft;
- [SerializeField]
- private ListViewerWindow m_WindowListFaceData;
- [SerializeField]
- private GameObject m_ParentAddFaceOptions;
- [SerializeField]
- private UIButton m_ButtonFaceListOK;
- private NGUIWindow m_FadeWindowShortcutButtonsRight;
- private NGUIWindow m_FadeWindowShortcutButtonsLeft;
- private NGUIWindow m_FadeWindowFaceDataList;
- private PhotoFaceDataShortcut.ItemData m_NowSelectItem;
- private Dictionary<PhotoFaceDataShortcut.ItemData, PhotoFaceDataShortcutSetter.ItemData> m_ItemPairDic = new Dictionary<PhotoFaceDataShortcut.ItemData, PhotoFaceDataShortcutSetter.ItemData>();
- private Dictionary<string, WFCheckBox> m_AddFaceOptionDic = new Dictionary<string, WFCheckBox>();
- public class ItemData : MonoBehaviour
- {
- public UILabel label
- {
- get
- {
- return this.m_Label;
- }
- set
- {
- this.m_Label = value;
- }
- }
- public Localize localize
- {
- get
- {
- return this.m_Localize;
- }
- set
- {
- this.m_Localize = value;
- }
- }
- private UILabel m_Label;
- private Localize m_Localize;
- }
- }
|