123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- public class PhotoFaceDataShortcut : MonoBehaviour
- {
- public List<PhotoFaceDataShortcut.ItemData> itemDataList
- {
- get
- {
- return this.m_ItemDataList;
- }
- }
- public bool IsLeftHand
- {
- get
- {
- return this.m_IsLeftHand;
- }
- set
- {
- this.m_IsLeftHand = value;
- }
- }
- public void Init(bool isLeftHand)
- {
- this.m_IsLeftHand = isLeftHand;
- CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI;
- circleCommandUI.onSelect.AddListener(new UnityAction<GameObject>(this.OnSelectItem));
- circleCommandUI.onDeselect.AddListener(new UnityAction<GameObject>(this.OnDeselectItem));
- circleCommandUI.onDecide.AddListener(new UnityAction<GameObject>(this.OnDecide));
- this.m_CircleList.controller = ((!isLeftHand) ? GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller : GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller);
- this.m_CircleList.SetActiveUI(true);
- GameObject childObject = UTY.GetChildObject(base.gameObject, "CircleCommandUI/text right hand", false);
- childObject.GetComponent<Text>().text = ((!isLeftHand) ? "右" : "左");
- childObject.GetComponent<Localize>().SetTerm("System/" + ((!isLeftHand) ? "右" : "左"));
- }
- public void CreateItemList(int count)
- {
- CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI;
- GameObject tempItem = circleCommandUI.listViewer.tempItem;
- Transform transform = tempItem.transform;
- transform.localScale = Vector3.one * 0.5f;
- this.itemDataList.Clear();
- PhotoFaceData.Create();
- circleCommandUI.Show<Transform>(count, delegate(int index, Transform trans)
- {
- Text componentInChildren = trans.GetComponentInChildren<Text>();
- Localize componentInChildren2 = trans.GetComponentInChildren<Localize>();
- PhotoFaceDataShortcut.ItemData itemData = trans.gameObject.AddComponent<PhotoFaceDataShortcut.ItemData>();
- itemData.handController = this;
- itemData.index = index;
- itemData.text = componentInChildren;
- itemData.localize = componentInChildren2;
- this.itemDataList.Add(itemData);
- });
- ControllerShortcutSettingData.LoadDefault();
- if (this.m_IsLeftHand)
- {
- List<PhotoFaceDataShortcut.FaceData> faceListLeft = ControllerShortcutSettingData.config.faceListLeft;
- for (int i = 0; i < faceListLeft.Count; i++)
- {
- if (i < this.itemDataList.Count)
- {
- this.itemDataList[i].faceData = faceListLeft[i];
- }
- }
- }
- else
- {
- List<PhotoFaceDataShortcut.FaceData> faceListRight = ControllerShortcutSettingData.config.faceListRight;
- for (int j = 0; j < faceListRight.Count; j++)
- {
- if (j < this.itemDataList.Count)
- {
- this.itemDataList[j].faceData = faceListRight[j];
- }
- }
- }
- }
- private void OnSelectItem(GameObject item)
- {
- if (item == null)
- {
- return;
- }
- Graphic component = item.GetComponent<Graphic>();
- if (component != null)
- {
- component.color = Color.red;
- }
- item.transform.localScale = Vector3.one;
- item.transform.SetAsLastSibling();
- if (ControllerShortcutSettingData.config.isDirectMode)
- {
- PhotoFaceDataShortcut.ItemData component2 = item.GetComponent<PhotoFaceDataShortcut.ItemData>();
- if (component2 != null)
- {
- this.ApplyMaidFace(this.GetMaid(), component2);
- }
- }
- }
- private void OnDeselectItem(GameObject item)
- {
- if (item == null)
- {
- return;
- }
- Graphic component = item.GetComponent<Graphic>();
- if (component != null)
- {
- Color white = Color.white;
- white.a = 0.5f;
- component.color = white;
- }
- item.transform.localScale = Vector3.one * 0.5f;
- }
- private void OnDecide(GameObject selectItem)
- {
- if (selectItem == null)
- {
- Debug.LogWarning("選択項目にnullが入った");
- return;
- }
- this.OnDeselectItem(selectItem);
- if (!ControllerShortcutSettingData.config.isEveryShowMode)
- {
- this.m_CircleList.SetActiveUI(false);
- }
- if (ControllerShortcutSettingData.config.isDirectMode)
- {
- return;
- }
- PhotoFaceDataShortcut.ItemData component = selectItem.GetComponent<PhotoFaceDataShortcut.ItemData>();
- if (component != null)
- {
- this.ApplyMaidFace(this.GetMaid(), component);
- }
- }
- private void ApplyMaidFace(Maid maid, PhotoFaceDataShortcut.ItemData itemData)
- {
- if (itemData == null || itemData.data == null)
- {
- Debug.Log("表情データにnullが指定されました。");
- return;
- }
- if (maid == null)
- {
- Debug.Log("メイドにnullが指定されました。");
- return;
- }
- maid.FaceAnime(itemData.data.setting_name, 0.5f, 0);
- maid.body0.Face.morph.SetValueOriginalBlendSet(itemData.blendType);
- maid.FaceBlend("オリジナル");
- maid.OpenMouth(itemData.isOpenMouth);
- Debug.Log(string.Concat(new object[]
- {
- "基本表情:",
- itemData.data.name,
- "\n追加表情:",
- itemData.blendType
- }));
- }
- public void Emulate(PhotoFaceDataShortcut.ItemData itemData)
- {
- if (!this.itemDataList.Contains(itemData))
- {
- Debug.Log("コントローラ上に存在しないデータを選んだ");
- return;
- }
- this.ApplyMaidFace(this.GetMaid(), itemData);
- }
- private Maid GetMaid()
- {
- CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
- return characterMgr.GetMaid(0);
- }
- [SerializeField]
- private CircleListSelectUI m_CircleList;
- private List<PhotoFaceDataShortcut.ItemData> m_ItemDataList = new List<PhotoFaceDataShortcut.ItemData>();
- private bool m_IsLeftHand;
- [Serializable]
- public class FaceData
- {
- public string dataName
- {
- get
- {
- return this.m_strData;
- }
- }
- public PhotoFaceData data
- {
- get
- {
- return this.m_Data;
- }
- set
- {
- this.m_Data = value;
- if (value == null)
- {
- this.m_strData = PhotoFaceDataShortcut.FaceData.strDataNull;
- }
- else
- {
- this.m_strData = value.setting_name;
- }
- }
- }
- public TMorph.AddBlendType blendType
- {
- get
- {
- return this.m_BlendType;
- }
- set
- {
- this.m_BlendType = value;
- }
- }
- public bool isOpenMouth
- {
- get
- {
- return this.m_IsOpenMouth;
- }
- set
- {
- this.m_IsOpenMouth = value;
- }
- }
- public static PhotoFaceDataShortcut.FaceData defaultData
- {
- get
- {
- if (PhotoFaceDataShortcut.FaceData.m_DefaultData == null)
- {
- PhotoFaceData.Create();
- PhotoFaceDataShortcut.FaceData.m_DefaultData = new PhotoFaceDataShortcut.FaceData();
- PhotoFaceDataShortcut.FaceData.m_DefaultData.data = PhotoFaceData.init_data;
- PhotoFaceDataShortcut.FaceData.m_DefaultData.m_strData = PhotoFaceDataShortcut.FaceData.strDataNull;
- PhotoFaceDataShortcut.FaceData.m_DefaultData.blendType = TMorph.AddBlendType.None;
- PhotoFaceDataShortcut.FaceData.m_DefaultData.isOpenMouth = false;
- }
- return PhotoFaceDataShortcut.FaceData.m_DefaultData;
- }
- }
- private PhotoFaceData m_Data;
- [SerializeField]
- private TMorph.AddBlendType m_BlendType;
- [SerializeField]
- private bool m_IsOpenMouth;
- [SerializeField]
- private string m_strData;
- private static string strDataNull = "通常";
- private static PhotoFaceDataShortcut.FaceData m_DefaultData;
- }
- public class ItemData : MonoBehaviour
- {
- public PhotoFaceDataShortcut handController { get; set; }
- public int index { get; set; }
- public PhotoFaceDataShortcut.FaceData faceData
- {
- get
- {
- return this.m_FaceData;
- }
- set
- {
- this.m_FaceData = value;
- this.UpdateData();
- }
- }
- public PhotoFaceData data
- {
- get
- {
- return this.m_FaceData.data;
- }
- set
- {
- this.m_FaceData.data = value;
- this.UpdateText();
- this.UpdateConfigData();
- }
- }
- public Text text
- {
- get
- {
- return this.m_Text;
- }
- set
- {
- this.m_Text = value;
- }
- }
- public Localize localize
- {
- get
- {
- return this.m_Localize;
- }
- set
- {
- this.m_Localize = value;
- }
- }
- public TMorph.AddBlendType blendType
- {
- get
- {
- return this.m_FaceData.blendType;
- }
- set
- {
- this.m_FaceData.blendType = value;
- }
- }
- public bool isOpenMouth
- {
- get
- {
- return this.m_FaceData.isOpenMouth;
- }
- set
- {
- this.m_FaceData.isOpenMouth = value;
- }
- }
- private void UpdateText()
- {
- if (this.text == null)
- {
- return;
- }
- this.text.text = this.GetDataName();
- this.localize.SetTerm(this.GetDataTermName());
- }
- public string GetDataName()
- {
- if (this.data == null)
- {
- return "無し";
- }
- return this.data.name;
- }
- public string GetDataTermName()
- {
- if (this.data == null)
- {
- return "無し";
- }
- return this.data.termName;
- }
- private void UpdateConfigData()
- {
- if (this.handController.IsLeftHand)
- {
- if (ControllerShortcutSettingData.config.faceListLeft.Count <= this.index)
- {
- return;
- }
- ControllerShortcutSettingData.config.faceListLeft[this.index] = this.faceData;
- }
- else
- {
- if (ControllerShortcutSettingData.config.faceListRight.Count <= this.index)
- {
- return;
- }
- ControllerShortcutSettingData.config.faceListRight[this.index] = this.faceData;
- }
- }
- private void UpdateData()
- {
- PhotoFaceDataShortcut.ItemData.CreatePhotoFaceDataNameDic();
- int num;
- if (PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic.TryGetValue(this.faceData.dataName, out num))
- {
- this.data = PhotoFaceData.Get((long)num);
- }
- else
- {
- this.data = null;
- }
- }
- private static void CreatePhotoFaceDataNameDic()
- {
- if (PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic != null && PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic.Count > 0)
- {
- return;
- }
- PhotoFaceData.Create();
- PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic = new SortedDictionary<string, int>();
- foreach (PhotoFaceData photoFaceData in PhotoFaceData.data)
- {
- PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic.Add(photoFaceData.setting_name, photoFaceData.id);
- }
- }
- public static SortedDictionary<string, int> photoFaceDataNameDic
- {
- get
- {
- PhotoFaceDataShortcut.ItemData.CreatePhotoFaceDataNameDic();
- return PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic;
- }
- private set
- {
- PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic = value;
- }
- }
- private PhotoFaceDataShortcut.FaceData m_FaceData = new PhotoFaceDataShortcut.FaceData();
- private Text m_Text;
- private Localize m_Localize;
- private static SortedDictionary<string, int> m_PhotoFaceDataNameDic;
- }
- }
|