using System; using System.Collections.Generic; using UnityEngine; using wf; public class WindowPartsFingerBlend : MonoBehaviour { public void Awake() { this.CheckBoxEnabled.check = false; this.CheckBoxEnabled.onClick.Add(new Action(this.OnClickFingerBlendEnabled)); this.InputFingerBlend.enabled = false; this.InputFingerBlend.onChangeValue.Add(new Action(this.OnChangetBlendValue)); this.BtnEnter.isEnabled = false; EventDelegate.Add(this.BtnEnter.onClick, new EventDelegate.Callback(this.OnClickEnter)); for (int i = 0; i < this.FingerLockCheckBox.Length; i++) { WFCheckBox wfcheckBox = this.FingerLockCheckBox[i]; bool flag = false; this.FingerLockCheckBox[i].enabled = flag; wfcheckBox.check = flag; this.FingerLockCheckBox[i].onClick.Add(new Action(this.OnClickFingerLockCheckBox)); } } public void OnMaidAddEvent(Maid maid, bool is_deserialize_load) { if (this.pose_edit_window_ == null) { this.pose_edit_window_ = (this.mgr.GetWindow(PhotoWindowManager.WindowType.PoseEdit) as PoseEditWindow); } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(maid); if (!maidStoreData.ContainsKey(this.store_str_enabled)) { maidStoreData[this.store_str_enabled] = false.ToString(); } if (!maidStoreData.ContainsKey(this.store_str_backup)) { maidStoreData[this.store_str_backup] = string.Empty; } if (!maidStoreData.ContainsKey(this.store_str_value)) { maidStoreData[this.store_str_value] = Vector2.zero.ToString("G9"); } for (int i = 0; i < this.FingerLockCheckBox.Length; i++) { if (!maidStoreData.ContainsKey(this.store_str_lockvalue + int.Parse(this.FingerLockCheckBox[i].name))) { maidStoreData[this.store_str_lockvalue + this.FingerLockCheckBox[i].name] = string.Empty; } } } public void ChangeEnabeled(bool use) { if (!use || this.mgr.select_maid == null) { WFCheckBox checkBoxEnabled = this.CheckBoxEnabled; bool flag = false; this.InputFingerBlend.enabled = flag; flag = flag; this.CheckBoxEnabled.enabled = flag; checkBoxEnabled.check = flag; PhotoSliderAndInput sliderAndInput = this.InputFingerBlend.GetSliderAndInput("x"); float value = 0f; this.InputFingerBlend.GetSliderAndInput("y").value = value; sliderAndInput.value = value; return; } this.CheckBoxEnabled.enabled = true; this.CheckBoxEnabled.check = bool.Parse(this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid)[this.store_str_enabled]); this.OnClickFingerBlendEnabled(this.CheckBoxEnabled); } public void OnMotionUpdate() { if (this.mgr.select_maid == null) { return; } if (this.CheckBoxEnabled.check) { this.CheckBoxEnabled.check = false; this.OnClickFingerBlendEnabled(this.CheckBoxEnabled); } } public void OnClickFingerBlendEnabled(WFCheckBox check_box) { if (this.mgr.select_maid == null) { WindowPartsInputSliderSet inputFingerBlend = this.InputFingerBlend; bool flag = false; this.BtnEnter.isEnabled = flag; inputFingerBlend.enabled = flag; for (int i = 0; i < this.FingerLockCheckBox.Length; i++) { this.FingerLockCheckBox[i].enabled = false; } return; } if (this.OnClickFingerBlendEnabledEvent != null) { this.OnClickFingerBlendEnabledEvent(this.BlendType, check_box.check); } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid); FingerBlend finger_blend = this.pose_edit_window_.ik_mgr.finger_blend; FingerBlend.BaseFinger baseFingerClass = this.GetBaseFingerClass(this.mgr.select_maid, this.BlendType); maidStoreData[this.store_str_enabled] = check_box.check.ToString(); WindowPartsInputSliderSet inputFingerBlend2 = this.InputFingerBlend; bool check = check_box.check; this.BtnEnter.isEnabled = check; inputFingerBlend2.enabled = check; for (int j = 0; j < this.FingerLockCheckBox.Length; j++) { WFCheckBox wfcheckBox = this.FingerLockCheckBox[j]; check = check_box.check; this.FingerLockCheckBox[j].check = check; wfcheckBox.enabled = check; } if (check_box.check && string.IsNullOrEmpty(maidStoreData[this.store_str_backup])) { maidStoreData[this.store_str_backup] = Convert.ToBase64String(baseFingerClass.GetBinary()); } else { if (!string.IsNullOrEmpty(maidStoreData[this.store_str_backup])) { byte[] data_byte = Convert.FromBase64String(maidStoreData[this.store_str_backup]); baseFingerClass.SetBinary(data_byte, false); } if (!check_box.check) { maidStoreData[this.store_str_backup] = string.Empty; } } Vector2 vector = Parse.Vector2(maidStoreData[this.store_str_value]); this.InputFingerBlend.GetSliderAndInput("x").value = vector.x; this.InputFingerBlend.GetSliderAndInput("y").value = vector.y; if (check_box.check) { for (int k = 0; k < this.FingerLockCheckBox.Length; k++) { string key = this.store_str_lockvalue + this.FingerLockCheckBox[k].name; this.FingerLockCheckBox[k].check = !string.IsNullOrEmpty(maidStoreData[key]); } } this.Apply(); } public void OnClickFingerLockCheckBox(WFCheckBox check_box) { if (this.mgr.select_maid == null) { return; } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid); if (!check_box.check) { maidStoreData[this.store_str_lockvalue + check_box.name] = string.Empty; } else if (string.IsNullOrEmpty(maidStoreData[this.store_str_lockvalue + check_box.name])) { Dictionary dictionary = maidStoreData; string key = this.store_str_lockvalue + check_box.name; Vector2 vector = new Vector2(this.InputFingerBlend.GetSliderAndInput("x").value, this.InputFingerBlend.GetSliderAndInput("y").value); dictionary[key] = vector.ToString(); } this.Apply(); } public void OnChangetBlendValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val) { if (this.mgr == null || this.mgr.select_maid == null) { if (input_object.Object.value != 0f) { input_object.Object.value = 0f; } return; } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid); if (!bool.Parse(maidStoreData["use"])) { if (input_object.Object.value != 0f) { input_object.Object.value = 0f; } return; } Vector2 vector = Parse.Vector2(maidStoreData[this.store_str_value]); if (input_object.Name == "x") { vector.x = val; } else { vector.y = val; } maidStoreData[this.store_str_value] = vector.ToString("G9"); this.Apply(); } public void OnClickEnter() { if (this.mgr.select_maid == null || !this.BtnEnter.isEnabled) { return; } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid); maidStoreData[this.store_str_backup] = string.Empty; this.CheckBoxEnabled.check = false; this.OnClickFingerBlendEnabled(this.CheckBoxEnabled); this.pose_edit_window_.ik_mgr.HistoryPush(); } public void ApplyPresetData(string base64_text, bool mirroring, bool history_push = true) { FingerBlend.BaseFinger baseFingerClass = this.GetBaseFingerClass(this.mgr.select_maid, this.BlendType); try { byte[] data_byte = Convert.FromBase64String(base64_text); baseFingerClass.SetBinary(data_byte, mirroring); if (history_push) { this.pose_edit_window_.ik_mgr.HistoryPush(); } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid); maidStoreData[this.store_str_backup] = string.Empty; this.CheckBoxEnabled.check = false; this.OnClickFingerBlendEnabled(this.CheckBoxEnabled); } catch { } } public void Apply() { if (this.mgr.select_maid == null) { return; } Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid); if (!bool.Parse(maidStoreData["use"])) { return; } FingerBlend.BaseFinger baseFingerClass = this.GetBaseFingerClass(this.mgr.select_maid, this.BlendType); baseFingerClass.enabled = bool.Parse(maidStoreData[this.store_str_enabled]); if (baseFingerClass.enabled) { for (int i = 0; i < this.FingerLockCheckBox.Length; i++) { int value_no = int.Parse(this.FingerLockCheckBox[i].name); if (this.FingerLockCheckBox[i].check) { string text = maidStoreData[this.store_str_lockvalue + this.FingerLockCheckBox[i].name]; if (string.IsNullOrEmpty(text)) { this.FingerLockCheckBox[i].check = false; baseFingerClass.LockSingleItem(false, value_no); } else { Vector2 value = Parse.Vector2(text); baseFingerClass.LockSingleItemValue(true, value_no, value); } } else { baseFingerClass.LockSingleItem(false, value_no); } } Vector2 vector = Parse.Vector2(maidStoreData[this.store_str_value]); baseFingerClass.value_open = vector.x; baseFingerClass.value_fist = vector.y; baseFingerClass.Apply(); } } public string store_str_enabled { get { return "finger_blend_enabled_" + this.BlendType.ToString(); } } public string store_str_backup { get { return "finger_blend_backup_" + this.BlendType.ToString(); } } public string store_str_value { get { return "finger_blend_value_" + this.BlendType.ToString(); } } public string store_str_lockvalue { get { return "finger_blend_lockvalue_" + this.BlendType.ToString(); } } public FingerBlend.BaseFinger GetBaseFingerClass(Maid maid, WindowPartsFingerBlend.Type type) { Dictionary maidStoreData = this.pose_edit_window_.GetMaidStoreData(maid); FingerBlend finger_blend = this.pose_edit_window_.ik_mgr.finger_blend; FingerBlend.BaseFinger result = null; if (type == WindowPartsFingerBlend.Type.RightArm) { result = finger_blend.right_arm_finger; } else if (type == WindowPartsFingerBlend.Type.LeftArm) { result = finger_blend.left_arm_finger; } else if (type == WindowPartsFingerBlend.Type.RightLeg) { result = finger_blend.right_leg_finger; } else if (type == WindowPartsFingerBlend.Type.LeftLeg) { result = finger_blend.left_leg_finger; } return result; } [HideInInspector] public PhotoWindowManager mgr; public WindowPartsFingerBlend.Type BlendType; public WFCheckBox CheckBoxEnabled; public WindowPartsInputSliderSet InputFingerBlend; public UIButton BtnEnter; public Action OnClickFingerBlendEnabledEvent; public WFCheckBox[] FingerLockCheckBox; private UIGrid[] grid_array_; private PoseEditWindow pose_edit_window_; public enum Type { RightArm, LeftArm, RightLeg, LeftLeg } }