WindowPartsInputColorrPalette.cs 4.6 KB

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