123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- 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<WFCheckBox>(this.OnClickFingerBlendEnabled));
- this.InputFingerBlend.enabled = false;
- this.InputFingerBlend.onChangeValue.Add(new Action<WindowPartsInputSliderSet.SliderAndInputSet, float>(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<WFCheckBox>(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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<WindowPartsFingerBlend.Type, bool> OnClickFingerBlendEnabledEvent;
- public WFCheckBox[] FingerLockCheckBox;
- private UIGrid[] grid_array_;
- private PoseEditWindow pose_edit_window_;
- public enum Type
- {
- RightArm,
- LeftArm,
- RightLeg,
- LeftLeg
- }
- }
|