WindowPartsInputSliderSet.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class WindowPartsInputSliderSet : MonoBehaviour
  6. {
  7. public void Awake()
  8. {
  9. for (int i = 0; i < this.SliderAndInput.Length; i++)
  10. {
  11. WindowPartsInputSliderSet.SliderAndInputSet target_obj = this.SliderAndInput[i];
  12. this.SliderAndInput[i].Object.onChangeValue.Add(delegate(float val)
  13. {
  14. WindowPartsInputSliderSet.SliderAndInputSet target_obj = target_obj;
  15. for (int k = 0; k < this.onChangeValue.Count; k++)
  16. {
  17. this.onChangeValue[k](target_obj, val);
  18. }
  19. });
  20. }
  21. this.btn_list_.Clear();
  22. if (this.ResetBtn != null)
  23. {
  24. this.btn_list_.Add(this.ResetBtn);
  25. EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnReset));
  26. EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  27. eventDelegate.parameters[0].value = "ScenePhotoMode/リセット";
  28. this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
  29. }
  30. if (this.CopyBtn != null)
  31. {
  32. this.btn_list_.Add(this.CopyBtn);
  33. EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnCopy));
  34. EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  35. eventDelegate.parameters[0].value = "ScenePhotoMode/コピー";
  36. this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
  37. }
  38. if (this.PasteBtn != null)
  39. {
  40. this.btn_list_.Add(this.PasteBtn);
  41. EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnPaste));
  42. EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  43. eventDelegate.parameters[0].value = "ScenePhotoMode/ペースト";
  44. this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
  45. }
  46. for (int j = 0; j < this.btn_list_.Count; j++)
  47. {
  48. EventDelegate.Add(this.btn_list_[j].gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
  49. EventDelegate.Add(this.btn_list_[j].gameObject.GetComponent<UIEventTrigger>().onRelease, new EventDelegate.Callback(this.OnMouseHoverOut));
  50. }
  51. this.OnReset();
  52. }
  53. public void SetValue(string name, float value)
  54. {
  55. for (int i = 0; i < this.SliderAndInput.Length; i++)
  56. {
  57. if (!(this.SliderAndInput[i].Name != name))
  58. {
  59. this.SliderAndInput[i].Object.value = value;
  60. break;
  61. }
  62. }
  63. }
  64. public float GetValue(string name)
  65. {
  66. float result = 0f;
  67. for (int i = 0; i < this.SliderAndInput.Length; i++)
  68. {
  69. if (!(this.SliderAndInput[i].Name != name))
  70. {
  71. result = this.SliderAndInput[i].Object.value;
  72. break;
  73. }
  74. }
  75. return result;
  76. }
  77. public PhotoSliderAndInput GetSliderAndInput(string name)
  78. {
  79. for (int i = 0; i < this.SliderAndInput.Length; i++)
  80. {
  81. if (!(this.SliderAndInput[i].Name != name))
  82. {
  83. return this.SliderAndInput[i].Object;
  84. }
  85. }
  86. return null;
  87. }
  88. public void OnReset()
  89. {
  90. for (int i = 0; i < this.SliderAndInput.Length; i++)
  91. {
  92. this.SliderAndInput[i].Object.ResetValue();
  93. }
  94. }
  95. public void OnCopy()
  96. {
  97. StringWriter stringWriter = new StringWriter();
  98. for (int i = 0; i < this.SliderAndInput.Length; i++)
  99. {
  100. stringWriter.WriteLine(this.SliderAndInput[i].Object.value);
  101. }
  102. for (int j = 0; j < this.onCopyEvent.Count; j++)
  103. {
  104. this.onCopyEvent[j](stringWriter);
  105. }
  106. BasePhotoWindowManager.SetCopyData(this.copy_data_title, stringWriter.ToString());
  107. }
  108. public void OnPaste()
  109. {
  110. string copyData = BasePhotoWindowManager.GetCopyData(this.copy_data_title);
  111. if (string.IsNullOrEmpty(copyData))
  112. {
  113. return;
  114. }
  115. StringReader stringReader = new StringReader(copyData);
  116. for (int i = 0; i < this.SliderAndInput.Length; i++)
  117. {
  118. this.SliderAndInput[i].Object.value = float.Parse(stringReader.ReadLine());
  119. }
  120. for (int j = 0; j < this.onPasteEvent.Count; j++)
  121. {
  122. this.onPasteEvent[j](stringReader);
  123. }
  124. }
  125. public void OnMouseHoverIn(string text)
  126. {
  127. MouseExposition @object = MouseExposition.GetObject();
  128. @object.textFromLanguageTerm = text;
  129. }
  130. public void OnMouseHoverOut()
  131. {
  132. MouseExposition @object = MouseExposition.GetObject();
  133. @object.text = string.Empty;
  134. }
  135. public new bool enabled
  136. {
  137. get
  138. {
  139. return this.SliderAndInput[0].Object.enabled;
  140. }
  141. set
  142. {
  143. for (int i = 0; i < this.SliderAndInput.Length; i++)
  144. {
  145. this.SliderAndInput[i].Object.enabled = value;
  146. }
  147. if (this.ResetBtn != null)
  148. {
  149. this.ResetBtn.isEnabled = value;
  150. }
  151. if (this.CopyBtn != null)
  152. {
  153. this.CopyBtn.isEnabled = value;
  154. }
  155. if (this.PasteBtn != null)
  156. {
  157. this.PasteBtn.isEnabled = value;
  158. }
  159. }
  160. }
  161. public bool visible
  162. {
  163. get
  164. {
  165. return base.gameObject.activeSelf;
  166. }
  167. set
  168. {
  169. base.gameObject.SetActive(value);
  170. }
  171. }
  172. public string copy_data_title
  173. {
  174. get
  175. {
  176. return this.CopyDataTitle;
  177. }
  178. }
  179. public WindowPartsInputSliderSet.SliderAndInputSet[] SliderAndInput;
  180. public UIButton ResetBtn;
  181. public UIButton CopyBtn;
  182. public UIButton PasteBtn;
  183. public string CopyDataTitle = "WindowPartsInputSliderSet";
  184. public List<Action<WindowPartsInputSliderSet.SliderAndInputSet, float>> onChangeValue = new List<Action<WindowPartsInputSliderSet.SliderAndInputSet, float>>();
  185. public List<Action<StringWriter>> onCopyEvent = new List<Action<StringWriter>>();
  186. public List<Action<StringReader>> onPasteEvent = new List<Action<StringReader>>();
  187. private List<UIButton> btn_list_ = new List<UIButton>();
  188. [Serializable]
  189. public class SliderAndInputSet
  190. {
  191. public string Name;
  192. public PhotoSliderAndInput Object;
  193. }
  194. }