HairLongWindow.cs 4.7 KB

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