FreeModeItemList.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using UnityEngine;
  5. using wf;
  6. public class FreeModeItemList : MonoBehaviour
  7. {
  8. public void Awake()
  9. {
  10. this.grid_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents/Grid", false).GetComponent<UIGrid>();
  11. this.scroll_view_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents", false).GetComponent<UIScrollView>();
  12. this.tab_pabel_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents/Grid", false).GetComponent<UIWFTabPanel>();
  13. this.info_label_ = UTY.GetChildObject(base.gameObject, "DetailParent/DetailBlock/Text", false).GetComponent<UILabel>();
  14. UIGrid component = UTY.GetChildObject(base.gameObject, "DetailParent/ConditionBlock/GridParent", false).GetComponent<UIGrid>();
  15. List<Transform> childList = component.GetChildList();
  16. for (int i = 0; i < childList.Count; i++)
  17. {
  18. this.condition_label_list_.Add(UTY.GetChildObject(childList[i].gameObject, "Message", false).GetComponent<UILabel>());
  19. }
  20. }
  21. public bool SetList(AbstractFreeModeItem[] item_list)
  22. {
  23. if (0 < this.grid_.gameObject.transform.childCount || item_list == null || item_list.Length <= 0)
  24. {
  25. return false;
  26. }
  27. this.select_item_data_ = null;
  28. UIWFTabButton uiwftabButton = null;
  29. for (int i = 0; i < item_list.Length; i++)
  30. {
  31. GameObject gameObject = Utility.CreatePrefab(this.grid_.gameObject, "SceneFreeModeSelect/FreeModeItemButton", true);
  32. UILabel component = UTY.GetChildObject(gameObject, "Name", false).GetComponent<UILabel>();
  33. Localize component2 = component.GetComponent<Localize>();
  34. component.text = item_list[i].title;
  35. if (component2 != null)
  36. {
  37. component2.SetTerm(item_list[i].titleTerm);
  38. }
  39. UIWFTabButton component3 = gameObject.GetComponent<UIWFTabButton>();
  40. component3.isEnabled = false;
  41. EventDelegate.Add(component3.onSelect, new EventDelegate.Callback(this.OnSelectItem));
  42. UIEventTrigger component4 = gameObject.GetComponent<UIEventTrigger>();
  43. EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  44. eventDelegate.parameters[0].value = component3;
  45. EventDelegate.Add(component4.onHoverOver, eventDelegate);
  46. EventDelegate.Add(component4.onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
  47. component4 = UTY.GetChildObject(gameObject, "HitRect", false).GetComponent<UIEventTrigger>();
  48. eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  49. eventDelegate.parameters[0].value = component3;
  50. EventDelegate.Add(component4.onHoverOver, eventDelegate);
  51. EventDelegate.Add(component4.onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
  52. bool is_enabled = item_list[i].is_enabled;
  53. if (is_enabled)
  54. {
  55. component3.isEnabled = true;
  56. UTY.GetChildObject(gameObject, "HitRect", false).SetActive(false);
  57. if (uiwftabButton == null)
  58. {
  59. uiwftabButton = component3;
  60. }
  61. }
  62. else
  63. {
  64. component3.isEnabled = false;
  65. UTY.GetChildObject(gameObject, "HitRect", false).SetActive(true);
  66. }
  67. this.item_obj_dic_.Add(gameObject, item_list[i]);
  68. }
  69. this.grid_.Reposition();
  70. this.scroll_view_.ResetPosition();
  71. this.tab_pabel_.UpdateChildren();
  72. if (uiwftabButton != null)
  73. {
  74. this.tab_pabel_.Select(uiwftabButton);
  75. }
  76. this.UpdateInfo(this.select_item_data_);
  77. return uiwftabButton != null;
  78. }
  79. public void OnSelectItem()
  80. {
  81. if (!UIWFTabButton.current.isSelected || !this.item_obj_dic_.ContainsKey(UIWFTabButton.current.gameObject))
  82. {
  83. return;
  84. }
  85. this.select_item_data_ = this.item_obj_dic_[UIWFTabButton.current.gameObject];
  86. this.UpdateInfo(this.select_item_data_);
  87. }
  88. private void OnMouseHoverIn(UIWFTabButton tab_btn)
  89. {
  90. this.UpdateInfo(this.item_obj_dic_[tab_btn.gameObject]);
  91. }
  92. private void OnMouseHoverOut()
  93. {
  94. this.UpdateInfo(this.select_item_data_);
  95. }
  96. public void UpdateInfo(AbstractFreeModeItem select_item_dat)
  97. {
  98. if (select_item_dat == null)
  99. {
  100. this.info_label_.text = string.Empty;
  101. for (int i = 0; i < this.condition_label_list_.Count; i++)
  102. {
  103. this.condition_label_list_[i].transform.parent.gameObject.SetActive(false);
  104. }
  105. }
  106. else
  107. {
  108. this.info_label_.text = select_item_dat.text;
  109. Localize component = this.info_label_.GetComponent<Localize>();
  110. if (component != null)
  111. {
  112. component.SetTerm(select_item_dat.textTerm);
  113. }
  114. string[] condition_text_terms = select_item_dat.condition_text_terms;
  115. for (int j = 0; j < this.condition_label_list_.Count; j++)
  116. {
  117. if (j < select_item_dat.condition_texts.Length)
  118. {
  119. this.condition_label_list_[j].transform.parent.gameObject.SetActive(true);
  120. this.condition_label_list_[j].text = select_item_dat.condition_texts[j];
  121. component = this.condition_label_list_[j].GetComponent<Localize>();
  122. if (component != null)
  123. {
  124. component.SetTerm(condition_text_terms[j]);
  125. }
  126. }
  127. else
  128. {
  129. this.condition_label_list_[j].transform.parent.gameObject.SetActive(false);
  130. }
  131. }
  132. }
  133. }
  134. public AbstractFreeModeItem select_item_data
  135. {
  136. get
  137. {
  138. return this.select_item_data_;
  139. }
  140. set
  141. {
  142. this.select_item_data_ = value;
  143. }
  144. }
  145. private Dictionary<GameObject, AbstractFreeModeItem> item_obj_dic_ = new Dictionary<GameObject, AbstractFreeModeItem>();
  146. private UIGrid grid_;
  147. private UIScrollView scroll_view_;
  148. private UIWFTabPanel tab_pabel_;
  149. private UILabel info_label_;
  150. private List<UILabel> condition_label_list_ = new List<UILabel>();
  151. private AbstractFreeModeItem select_item_data_;
  152. }