HairLongWindow.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class HairLongWindow : BasePhotoWindow
  5. {
  6. public override string windowName
  7. {
  8. get
  9. {
  10. return "HairLongWindow";
  11. }
  12. }
  13. public override void Start()
  14. {
  15. base.Start();
  16. this.m_goParent = base.transform.Find("Parent").gameObject;
  17. this.m_goDummySlider = base.transform.Find("Parent/ContentParent/GameObject/EditTool/InputScale").gameObject;
  18. this.m_goDummySlider.SetActive(false);
  19. this.visible = false;
  20. this.UpdateChildren();
  21. }
  22. private void ClearSliders()
  23. {
  24. for (int i = 0; i < this.m_listSliders.Count; i++)
  25. {
  26. this.m_listSliders[i].Remove();
  27. }
  28. this.m_listSliders.Clear();
  29. }
  30. public override void Update()
  31. {
  32. if (SceneEdit.Instance != null && SceneEdit.Instance.maid != null && (SceneEdit.Instance.NowMPN == MPN.hairf || SceneEdit.Instance.NowMPN == MPN.hairr || SceneEdit.Instance.NowMPN == MPN.hairs || SceneEdit.Instance.NowMPN == MPN.hairt))
  33. {
  34. if (SceneEdit.Instance.maid.IsBusy)
  35. {
  36. return;
  37. }
  38. if (this.m_mpnBackActive == MPN.null_mpn || this.m_mpnBackActive != SceneEdit.Instance.NowMPN || SceneEdit.Instance.maid.GetProp(SceneEdit.Instance.NowMPN).nFileNameRID != this.m_nRID)
  39. {
  40. this.ClearSliders();
  41. Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> hairLengthListFromMPN = SceneEdit.Instance.maid.body0.GetHairLengthListFromMPN(SceneEdit.Instance.NowMPN);
  42. if (hairLengthListFromMPN != null)
  43. {
  44. foreach (KeyValuePair<string, TBodySkin.HairLengthCtrl.HairLength> f_kvNameAndHl in hairLengthListFromMPN)
  45. {
  46. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goDummySlider);
  47. gameObject.transform.SetParent(this.m_goDummySlider.transform.parent);
  48. gameObject.transform.localPosition = this.m_goDummySlider.transform.localPosition;
  49. gameObject.transform.localPosition = new Vector3(gameObject.transform.localPosition.x, 76f - 64f * (float)this.m_listSliders.Count, gameObject.transform.localPosition.z);
  50. gameObject.transform.localScale = this.m_goDummySlider.transform.localScale;
  51. gameObject.transform.localRotation = this.m_goDummySlider.transform.localRotation;
  52. gameObject.SetActive(true);
  53. this.m_listSliders.Add(new HairLongWindow.EditBone(gameObject, f_kvNameAndHl, SceneEdit.Instance.maid));
  54. }
  55. }
  56. this.WindowSize.y = 120f + (float)(this.m_listSliders.Count - 1) * 64f;
  57. base.ResizeWindow();
  58. }
  59. this.m_nRID = SceneEdit.Instance.maid.GetProp(SceneEdit.Instance.NowMPN).nFileNameRID;
  60. this.m_mpnBackActive = SceneEdit.Instance.NowMPN;
  61. }
  62. else
  63. {
  64. this.ClearSliders();
  65. this.m_nRID = 0;
  66. this.m_mpnBackActive = MPN.null_mpn;
  67. }
  68. if (this.visible != (this.m_listSliders.Count != 0))
  69. {
  70. this.visible = (this.m_listSliders.Count != 0);
  71. }
  72. }
  73. private GameObject m_goParent;
  74. private GameObject m_goDummySlider;
  75. private MPN m_mpnBackActive;
  76. private List<HairLongWindow.EditBone> m_listSliders = new List<HairLongWindow.EditBone>();
  77. private int m_nRID;
  78. private class EditBone
  79. {
  80. public EditBone(GameObject f_goRoot, KeyValuePair<string, TBodySkin.HairLengthCtrl.HairLength> f_kvNameAndHl, Maid f_maid)
  81. {
  82. this.root = f_goRoot;
  83. this.hl = f_kvNameAndHl.Value;
  84. this.m_maid = f_maid;
  85. this.label = this.root.transform.Find("Text").GetComponent<UILabel>();
  86. this.slider = this.root.GetComponent<PhotoSliderAndInput>();
  87. this.slider.MinNum = 0f;
  88. this.slider.MaxNum = 100f;
  89. this.slider.ResetNum = 50f;
  90. this.slider.onChangeValue.Add(new Action<float>(this.OnChangeValue));
  91. this.label.text = f_kvNameAndHl.Key;
  92. this.slider.value = (this.m_fBackValue = this.hl.GetLengthRate() * 100f);
  93. }
  94. public void OnChangeValue(float f_fValue)
  95. {
  96. this.hl.SetLengthRate(f_fValue / 100f);
  97. if (this.m_fBackValue != f_fValue)
  98. {
  99. this.m_maid.body0.HairLengthBlend();
  100. }
  101. this.m_fBackValue = f_fValue;
  102. }
  103. public void Remove()
  104. {
  105. UnityEngine.Object.DestroyImmediate(this.root);
  106. }
  107. public GameObject root;
  108. public UILabel label;
  109. public PhotoSliderAndInput slider;
  110. public TBodySkin.HairLengthCtrl.HairLength hl;
  111. private Maid m_maid;
  112. private float m_fBackValue = 50f;
  113. }
  114. }