123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Xml.Linq;
- using UnityEngine;
- using wf;
- public class WindowPartsFingerPreset : MonoBehaviour
- {
- public void Awake()
- {
- this.PresetLoad.CheckBoxPresetVisibleSwitch.check = false;
- this.PresetLoad.CheckBoxPresetVisibleSwitch.onClick.Add(new Action<WFCheckBox>(this.OnClickPresetSwitch));
- for (int i = 0; i < this.PresetSaveBtnDataArray.Length; i++)
- {
- EventDelegate.Add(this.PresetSaveBtnDataArray[i].btn.onClick, new EventDelegate.Callback(this.OnClickPresetSave));
- }
- if (this.RightCopyToLeft != null)
- {
- EventDelegate.Add(this.RightCopyToLeft.onClick, new EventDelegate.Callback(this.OnClickRightCopyToLeft));
- EventDelegate eventDelegate = new EventDelegate(this, "OnBtnMouseHoverIn");
- eventDelegate.parameters[0].value = "ScenePhotoMode/Pエディット/左へコピー";
- this.RightCopyToLeft.gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
- EventDelegate.Add(this.RightCopyToLeft.gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- }
- if (this.LeftCopyToRight != null)
- {
- EventDelegate.Add(this.LeftCopyToRight.onClick, new EventDelegate.Callback(this.OnClickLeftCopyToLeft));
- EventDelegate eventDelegate2 = new EventDelegate(this, "OnBtnMouseHoverIn");
- eventDelegate2.parameters[0].value = "ScenePhotoMode/Pエディット/右へコピー";
- this.LeftCopyToRight.gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate2);
- EventDelegate.Add(this.LeftCopyToRight.gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- }
- if (this.Swap != null)
- {
- EventDelegate.Add(this.Swap.onClick, new EventDelegate.Callback(this.OnClickSwap));
- EventDelegate eventDelegate3 = new EventDelegate(this, "OnBtnMouseHoverIn");
- eventDelegate3.parameters[0].value = "ScenePhotoMode/Pエディット/交換";
- this.Swap.gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate3);
- EventDelegate.Add(this.Swap.gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- }
- }
- public void Start()
- {
- this.OnClickPresetSwitch(this.PresetLoad.CheckBoxPresetVisibleSwitch);
- }
- public void OnClickPresetSwitch(WFCheckBox check_box)
- {
- if (check_box.check)
- {
- this.PresetLoad.PresetList.SetActive(true);
- foreach (GameObject gameObject in this.HideObjectArray)
- {
- gameObject.SetActive(false);
- }
- this.UpdatePresetList();
- }
- else
- {
- this.PresetLoad.PresetList.SetActive(false);
- foreach (GameObject gameObject2 in this.HideObjectArray)
- {
- gameObject2.SetActive(true);
- }
- }
- }
- private void UpdatePresetList()
- {
- if (this.PresetLoad.Grid == null)
- {
- return;
- }
- UIGrid grid = this.PresetLoad.Grid;
- List<Transform> childList = grid.GetChildList();
- for (int i = 0; i < childList.Count; i++)
- {
- UnityEngine.Object.DestroyImmediate(childList[i].gameObject);
- }
- Action<string, List<string>> action = delegate(string path, List<string> result_list)
- {
- string[] files = Directory.GetFiles(path);
- for (int j = 0; j < files.Length; j++)
- {
- if (Path.GetExtension(files[j]) == ".xml")
- {
- result_list.Add(files[j]);
- }
- }
- };
- List<string> list = new List<string>();
- action(this.GetFolderPath(this.PresetLoad.type), list);
- foreach (string path2 in list)
- {
- GameObject gameObject = Utility.CreatePrefab(grid.gameObject, "ScenePhotoMode/WindowListItemFingerPresetButton", true);
- gameObject.name = Path.GetFileNameWithoutExtension(path2);
- UTY.GetChildObject(gameObject, "Text", false).GetComponent<UILabel>().text = gameObject.name;
- EventDelegate.Add(UTY.GetChildObject(gameObject, "LeftBtn", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnClickPresetBtnLeft));
- UTY.GetChildObject(gameObject, "LeftBtn", false).name = gameObject.name;
- EventDelegate.Add(UTY.GetChildObject(gameObject, "RightBtn", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnClickPresetBtnRight));
- UTY.GetChildObject(gameObject, "RightBtn", false).name = gameObject.name;
- }
- grid.Reposition();
- NGUITools.FindInParents<UIScrollView>(grid.transform).ResetPosition();
- }
- public void OnClickPresetBtnRight()
- {
- this.OnClickPresetBtn(this.PresetLoad.right_blend);
- }
- public void OnClickPresetBtnLeft()
- {
- this.OnClickPresetBtn(this.PresetLoad.left_blend);
- }
- public void OnClickPresetBtn(WindowPartsFingerBlend target)
- {
- string name = UIButton.current.name;
- string text = this.GetFolderPath(this.PresetLoad.type) + "/" + name + ".xml";
- if (!File.Exists(text))
- {
- return;
- }
- XDocument xdocument = XDocument.Load(text);
- XElement xelement = xdocument.Element("FingerData");
- if (xelement.IsEmpty || xelement.Element("GameVersion").IsEmpty || xelement.Element("RightData").IsEmpty || xelement.Element("BinaryData").IsEmpty)
- {
- return;
- }
- bool flag = bool.Parse(xelement.Element("RightData").Value);
- string value = xelement.Element("BinaryData").Value;
- bool mirroring;
- if (flag)
- {
- mirroring = (target.BlendType != WindowPartsFingerBlend.Type.RightArm && target.BlendType != WindowPartsFingerBlend.Type.RightLeg);
- }
- else
- {
- mirroring = (target.BlendType != WindowPartsFingerBlend.Type.LeftArm && target.BlendType != WindowPartsFingerBlend.Type.LeftLeg);
- }
- target.ApplyPresetData(value, mirroring, true);
- }
- private void OnClickRightCopyToLeft()
- {
- FingerBlend.BaseFinger baseFingerClass = this.RightFingerBlend.GetBaseFingerClass(this.RightFingerBlend.mgr.select_maid, this.RightFingerBlend.BlendType);
- this.LeftFingerBlend.ApplyPresetData(Convert.ToBase64String(baseFingerClass.GetBinary()), true, true);
- }
- private void OnClickLeftCopyToLeft()
- {
- FingerBlend.BaseFinger baseFingerClass = this.LeftFingerBlend.GetBaseFingerClass(this.LeftFingerBlend.mgr.select_maid, this.LeftFingerBlend.BlendType);
- this.RightFingerBlend.ApplyPresetData(Convert.ToBase64String(baseFingerClass.GetBinary()), true, true);
- }
- private void OnClickSwap()
- {
- FingerBlend.BaseFinger baseFingerClass = this.RightFingerBlend.GetBaseFingerClass(this.RightFingerBlend.mgr.select_maid, this.RightFingerBlend.BlendType);
- string base64_text = Convert.ToBase64String(baseFingerClass.GetBinary());
- baseFingerClass = this.LeftFingerBlend.GetBaseFingerClass(this.LeftFingerBlend.mgr.select_maid, this.LeftFingerBlend.BlendType);
- string base64_text2 = Convert.ToBase64String(baseFingerClass.GetBinary());
- this.LeftFingerBlend.ApplyPresetData(base64_text, true, false);
- this.RightFingerBlend.ApplyPresetData(base64_text2, true, true);
- }
- private void OnClickPresetSave()
- {
- foreach (WindowPartsFingerPreset.PresetSaveData presetSaveData in this.PresetSaveBtnDataArray)
- {
- if (presetSaveData.btn == UIButton.current)
- {
- this.PresetSave(presetSaveData.window_finger_blend);
- break;
- }
- }
- }
- private void PresetSave(WindowPartsFingerBlend tareget_blend)
- {
- WindowPartsFingerBlend.Type blendType = tareget_blend.BlendType;
- FingerBlend.BaseFinger baseFingerClass = tareget_blend.GetBaseFingerClass(tareget_blend.mgr.select_maid, blendType);
- XElement xelement = new XElement("GameVersion", 1430);
- XElement xelement2 = new XElement("RightData", blendType == WindowPartsFingerBlend.Type.RightArm || blendType == WindowPartsFingerBlend.Type.RightLeg);
- XElement xelement3 = new XElement("BinaryData", Convert.ToBase64String(baseFingerClass.GetBinary()));
- XNode[] contents = new XNode[]
- {
- xelement,
- xelement2,
- xelement3
- };
- XElement xelement4 = new XElement("FingerData", contents);
- XDocument save_target_xml = new XDocument(new XDeclaration("1.0", "utf-8", "true"), new object[]
- {
- new XComment("CM3D2 FingerData"),
- xelement4
- });
- string save_dir_name = "arm";
- if (blendType == WindowPartsFingerBlend.Type.RightLeg || blendType == WindowPartsFingerBlend.Type.LeftLeg)
- {
- save_dir_name = "leg";
- }
- this.PoseEditWindow.PanelSave.OpenFingerSaveMode(save_target_xml, save_dir_name, null);
- }
- private void OnBtnMouseHoverIn(string text)
- {
- MouseExposition @object = MouseExposition.GetObject();
- @object.textFromLanguageTerm = text;
- }
- private void OnMouseHoverOut()
- {
- MouseExposition @object = MouseExposition.GetObject();
- @object.text = string.Empty;
- }
- private string GetFolderPath(WindowPartsFingerBlend.Type type)
- {
- if (!Directory.Exists(PhotoWindowManager.path_photo_folder + "FingerData"))
- {
- Directory.CreateDirectory(PhotoWindowManager.path_photo_folder + "FingerData");
- }
- string str = "arm";
- if (type == WindowPartsFingerBlend.Type.RightLeg || type == WindowPartsFingerBlend.Type.LeftLeg)
- {
- str = "leg";
- }
- string text = PhotoWindowManager.path_photo_folder + "FingerData/" + str;
- if (!Directory.Exists(text))
- {
- Directory.CreateDirectory(text);
- }
- return text;
- }
- private string GetFolderPath(WindowPartsFingerPreset.PresetLoadData.Type type)
- {
- return this.GetFolderPath((type != WindowPartsFingerPreset.PresetLoadData.Type.Arm) ? WindowPartsFingerBlend.Type.RightLeg : WindowPartsFingerBlend.Type.RightArm);
- }
- public PoseEditWindow PoseEditWindow;
- public WindowPartsFingerPreset.PresetSaveData[] PresetSaveBtnDataArray;
- public WindowPartsFingerPreset.PresetLoadData PresetLoad;
- public GameObject[] HideObjectArray;
- public WindowPartsFingerBlend RightFingerBlend;
- public WindowPartsFingerBlend LeftFingerBlend;
- public UIButton RightCopyToLeft;
- public UIButton LeftCopyToRight;
- public UIButton Swap;
- [Serializable]
- public class PresetSaveData
- {
- public WindowPartsFingerBlend window_finger_blend;
- public UIButton btn;
- }
- [Serializable]
- public class PresetLoadData
- {
- public UIGrid Grid
- {
- get
- {
- if (this.grid_ == null)
- {
- this.grid_ = this.PresetList.GetComponentInChildren<UIGrid>();
- }
- return this.grid_;
- }
- }
- public WindowPartsFingerPreset.PresetLoadData.Type type;
- public WFCheckBox CheckBoxPresetVisibleSwitch;
- public WindowPartsFingerBlend right_blend;
- public WindowPartsFingerBlend left_blend;
- public GameObject PresetList;
- private UIGrid grid_;
- public enum Type
- {
- Arm,
- Leg
- }
- }
- }
|