BasePhotoSubWindow.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BasePhotoSubWindow : MonoBehaviour
  5. {
  6. protected void ResizeWindow()
  7. {
  8. int num = (int)this.WindowSize.x;
  9. int num2 = (int)this.WindowSize.y;
  10. this.WindowSize.x = (float)num;
  11. this.WindowSize.y = (float)num2;
  12. UTY.GetChildObject(base.gameObject, "Parent", false).GetComponent<BoxCollider>().size = new Vector3((float)num, (float)num2, 1f);
  13. UTY.GetChildObject(base.gameObject, "Parent", false).GetComponent<BoxCollider>().center = new Vector3((float)(num - 200) / 2f, (float)(num2 - 200) / -2f, 1f);
  14. UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent<UIWidget>().width = num;
  15. UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent<UIWidget>().height = num2;
  16. UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent<UIWidget>().width = num;
  17. UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent<UIWidget>().height = num2 - 20;
  18. UTY.GetChildObject(base.gameObject, "Parent/BG2", false).transform.localPosition = new Vector3(-100f, (float)((num2 - 100) * -1), 0f);
  19. UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar", false).GetComponent<UIWidget>().width = num;
  20. UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar/Btn", false).transform.localPosition = new Vector3((float)(num - 10), -10f, 0f);
  21. UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar/Text", false).GetComponent<UILabel>().text = this.InitTitle;
  22. }
  23. public virtual void Initizalize(BasePhotoWindow parentWindow)
  24. {
  25. if (this.content_game_object_ != null)
  26. {
  27. return;
  28. }
  29. this.parent_window_ = parentWindow;
  30. this.ResizeWindow();
  31. this.content_game_object_ = UTY.GetChildObject(base.gameObject, "Parent/ContentParent", false);
  32. GameObject childObject = UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar", false);
  33. if (this.panel_ == null)
  34. {
  35. this.panel_ = base.GetComponentInChildren<UIPanel>();
  36. }
  37. this.title_bar_label_ = UTY.GetChildObject(childObject, "Text", false).GetComponent<UILabel>();
  38. Dictionary<BasePhotoSubWindow.BtnType, string> dictionary = new Dictionary<BasePhotoSubWindow.BtnType, string>();
  39. dictionary.Add(BasePhotoSubWindow.BtnType.Help, "ヘルプ");
  40. dictionary.Add(BasePhotoSubWindow.BtnType.Min, "最小化");
  41. dictionary.Add(BasePhotoSubWindow.BtnType.Reset, "UI位置初期化");
  42. dictionary.Add(BasePhotoSubWindow.BtnType.End, "閉じる");
  43. this.btn_dic_ = new Dictionary<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>>();
  44. for (int i = 0; i <= 3; i++)
  45. {
  46. BasePhotoSubWindow.BtnType key = (BasePhotoSubWindow.BtnType)i;
  47. this.btn_dic_.Add(key, new KeyValuePair<UIButton, List<Action>>(UTY.GetChildObject(childObject, "Btn/" + key.ToString(), false).GetComponent<UIButton>(), new List<Action>()));
  48. EventDelegate.Add(this.btn_dic_[key].Key.onClick, new EventDelegate.Callback(this.OnButtonClickEvent));
  49. this.mini_btn_init_pos_.Add(key, this.btn_dic_[key].Key.transform.localPosition);
  50. if (dictionary.ContainsKey(key))
  51. {
  52. UIButton key2 = this.btn_dic_[key].Key;
  53. EventDelegate eventDelegate = new EventDelegate(this, "OnBtnMouseHoverIn");
  54. eventDelegate.parameters[0].value = dictionary[key];
  55. key2.gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
  56. EventDelegate.Add(key2.gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
  57. }
  58. }
  59. this.window_active_delegate_ = new EventDelegate(new EventDelegate.Callback(parentWindow.ActiveWindow));
  60. this.init_pos_ = base.transform.localPosition;
  61. for (int j = 0; j <= 3; j++)
  62. {
  63. this.SetButtonEnabled((BasePhotoSubWindow.BtnType)j, false, false);
  64. }
  65. this.GetButtonOnClickEventList(BasePhotoSubWindow.BtnType.Reset).Add(delegate
  66. {
  67. this.ResetPosition();
  68. });
  69. if (!this.InitVisible)
  70. {
  71. this.visible = false;
  72. }
  73. }
  74. public void SetButtonEnabled(BasePhotoSubWindow.BtnType type, bool enabled, bool force_update = false)
  75. {
  76. this.btn_dic_[type].Key.gameObject.SetActive(enabled);
  77. foreach (KeyValuePair<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>> keyValuePair in this.btn_dic_)
  78. {
  79. keyValuePair.Value.Key.transform.localPosition = this.mini_btn_init_pos_[keyValuePair.Key];
  80. }
  81. UIGrid component = this.btn_dic_[BasePhotoSubWindow.BtnType.Help].Key.transform.parent.gameObject.GetComponent<UIGrid>();
  82. if (component != null)
  83. {
  84. if (force_update)
  85. {
  86. component.Reposition();
  87. }
  88. else
  89. {
  90. component.repositionNow = true;
  91. }
  92. }
  93. }
  94. public List<Action> GetButtonOnClickEventList(BasePhotoSubWindow.BtnType type)
  95. {
  96. return this.btn_dic_[type].Value;
  97. }
  98. public virtual void OnButtonClickEvent()
  99. {
  100. int instanceID = UIButton.current.GetInstanceID();
  101. foreach (KeyValuePair<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>> keyValuePair in this.btn_dic_)
  102. {
  103. if (instanceID == keyValuePair.Value.Key.GetInstanceID())
  104. {
  105. List<Action> value = keyValuePair.Value.Value;
  106. for (int i = 0; i < value.Count; i++)
  107. {
  108. value[i]();
  109. }
  110. }
  111. }
  112. }
  113. public virtual void ResetPosition()
  114. {
  115. base.transform.localPosition = this.init_pos_;
  116. }
  117. public virtual void OnActiveChangeWindowEvent(bool is_active)
  118. {
  119. }
  120. public string title
  121. {
  122. get
  123. {
  124. return this.title_bar_label_.text;
  125. }
  126. set
  127. {
  128. this.title_bar_label_.text = value;
  129. }
  130. }
  131. public int depth
  132. {
  133. get
  134. {
  135. return this.panel.GetComponentInChildren<UIPanel>().depth / 10;
  136. }
  137. set
  138. {
  139. int num = value * 10;
  140. UIPanel[] componentsInChildren = this.panel.gameObject.GetComponentsInChildren<UIPanel>(true);
  141. for (int i = 0; i < componentsInChildren.Length; i++)
  142. {
  143. componentsInChildren[i].depth = num++;
  144. }
  145. }
  146. }
  147. public bool visible
  148. {
  149. get
  150. {
  151. return this.panel.alpha != 0f;
  152. }
  153. set
  154. {
  155. this.panel.alpha = (float)((!value) ? 0 : 1);
  156. }
  157. }
  158. public UIPanel panel
  159. {
  160. get
  161. {
  162. if (this.panel_ == null)
  163. {
  164. this.panel_ = base.GetComponentInChildren<UIPanel>();
  165. }
  166. return this.panel_;
  167. }
  168. }
  169. public EventDelegate window_active_delegate
  170. {
  171. get
  172. {
  173. return this.window_active_delegate_;
  174. }
  175. }
  176. public virtual GameObject content_game_object
  177. {
  178. get
  179. {
  180. return this.content_game_object_;
  181. }
  182. }
  183. public BasePhotoWindowManager mgr
  184. {
  185. get
  186. {
  187. return this.parent_window_.mgr;
  188. }
  189. }
  190. protected void OnBtnMouseHoverIn(string text)
  191. {
  192. MouseExposition @object = MouseExposition.GetObject();
  193. @object.text = text;
  194. }
  195. protected void OnMouseHoverOut()
  196. {
  197. MouseExposition @object = MouseExposition.GetObject();
  198. @object.text = string.Empty;
  199. }
  200. public string InitTitle = "キャラクター";
  201. public Vector2 WindowSize;
  202. public bool InitVisible = true;
  203. protected BasePhotoWindow parent_window_;
  204. protected UILabel title_bar_label_;
  205. protected UIPanel panel_;
  206. protected BasePhotoWindowManager mgr_;
  207. protected Dictionary<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>> btn_dic_;
  208. protected EventDelegate window_active_delegate_;
  209. protected GameObject content_game_object_;
  210. protected Vector3 init_pos_;
  211. private Dictionary<BasePhotoSubWindow.BtnType, Vector3> mini_btn_init_pos_ = new Dictionary<BasePhotoSubWindow.BtnType, Vector3>();
  212. public enum BtnType
  213. {
  214. Help,
  215. Reset,
  216. Min,
  217. End
  218. }
  219. }