123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- using wf;
- public class FreeModeItemList : MonoBehaviour
- {
- public void Awake()
- {
- this.grid_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents/Grid", false).GetComponent<UIGrid>();
- this.scroll_view_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents", false).GetComponent<UIScrollView>();
- this.tab_pabel_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents/Grid", false).GetComponent<UIWFTabPanel>();
- this.info_label_ = UTY.GetChildObject(base.gameObject, "DetailParent/DetailBlock/Text", false).GetComponent<UILabel>();
- UIGrid component = UTY.GetChildObject(base.gameObject, "DetailParent/ConditionBlock/GridParent", false).GetComponent<UIGrid>();
- List<Transform> childList = component.GetChildList();
- for (int i = 0; i < childList.Count; i++)
- {
- this.condition_label_list_.Add(UTY.GetChildObject(childList[i].gameObject, "Message", false).GetComponent<UILabel>());
- }
- }
- public bool SetList(AbstractFreeModeItem[] item_list)
- {
- if (0 < this.grid_.gameObject.transform.childCount || item_list == null || item_list.Length <= 0)
- {
- return false;
- }
- this.select_item_data_ = null;
- UIWFTabButton uiwftabButton = null;
- for (int i = 0; i < item_list.Length; i++)
- {
- GameObject gameObject = Utility.CreatePrefab(this.grid_.gameObject, "SceneFreeModeSelect/FreeModeItemButton", true);
- UILabel component = UTY.GetChildObject(gameObject, "Name", false).GetComponent<UILabel>();
- Localize component2 = component.GetComponent<Localize>();
- component.text = item_list[i].title;
- if (component2 != null)
- {
- component2.SetTerm(item_list[i].titleTerm);
- }
- UIWFTabButton component3 = gameObject.GetComponent<UIWFTabButton>();
- component3.isEnabled = false;
- EventDelegate.Add(component3.onSelect, new EventDelegate.Callback(this.OnSelectItem));
- UIEventTrigger component4 = gameObject.GetComponent<UIEventTrigger>();
- EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
- eventDelegate.parameters[0].value = component3;
- EventDelegate.Add(component4.onHoverOver, eventDelegate);
- EventDelegate.Add(component4.onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- component4 = UTY.GetChildObject(gameObject, "HitRect", false).GetComponent<UIEventTrigger>();
- eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
- eventDelegate.parameters[0].value = component3;
- EventDelegate.Add(component4.onHoverOver, eventDelegate);
- EventDelegate.Add(component4.onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- bool is_enabled = item_list[i].is_enabled;
- if (is_enabled)
- {
- component3.isEnabled = true;
- UTY.GetChildObject(gameObject, "HitRect", false).SetActive(false);
- if (uiwftabButton == null)
- {
- uiwftabButton = component3;
- }
- }
- else
- {
- component3.isEnabled = false;
- UTY.GetChildObject(gameObject, "HitRect", false).SetActive(true);
- }
- this.item_obj_dic_.Add(gameObject, item_list[i]);
- }
- this.grid_.Reposition();
- this.scroll_view_.ResetPosition();
- this.tab_pabel_.UpdateChildren();
- if (uiwftabButton != null)
- {
- this.tab_pabel_.Select(uiwftabButton);
- }
- this.UpdateInfo(this.select_item_data_);
- return uiwftabButton != null;
- }
- public void OnSelectItem()
- {
- if (!UIWFTabButton.current.isSelected || !this.item_obj_dic_.ContainsKey(UIWFTabButton.current.gameObject))
- {
- return;
- }
- this.select_item_data_ = this.item_obj_dic_[UIWFTabButton.current.gameObject];
- this.UpdateInfo(this.select_item_data_);
- }
- private void OnMouseHoverIn(UIWFTabButton tab_btn)
- {
- this.UpdateInfo(this.item_obj_dic_[tab_btn.gameObject]);
- }
- private void OnMouseHoverOut()
- {
- this.UpdateInfo(this.select_item_data_);
- }
- public void UpdateInfo(AbstractFreeModeItem select_item_dat)
- {
- if (select_item_dat == null)
- {
- this.info_label_.text = string.Empty;
- for (int i = 0; i < this.condition_label_list_.Count; i++)
- {
- this.condition_label_list_[i].transform.parent.gameObject.SetActive(false);
- }
- }
- else
- {
- this.info_label_.text = select_item_dat.text;
- Localize component = this.info_label_.GetComponent<Localize>();
- if (component != null)
- {
- component.SetTerm(select_item_dat.textTerm);
- }
- string[] condition_text_terms = select_item_dat.condition_text_terms;
- for (int j = 0; j < this.condition_label_list_.Count; j++)
- {
- if (j < select_item_dat.condition_texts.Length)
- {
- this.condition_label_list_[j].transform.parent.gameObject.SetActive(true);
- this.condition_label_list_[j].text = select_item_dat.condition_texts[j];
- component = this.condition_label_list_[j].GetComponent<Localize>();
- if (component != null)
- {
- component.SetTerm(condition_text_terms[j]);
- }
- }
- else
- {
- this.condition_label_list_[j].transform.parent.gameObject.SetActive(false);
- }
- }
- }
- }
- public AbstractFreeModeItem select_item_data
- {
- get
- {
- return this.select_item_data_;
- }
- set
- {
- this.select_item_data_ = value;
- }
- }
- private Dictionary<GameObject, AbstractFreeModeItem> item_obj_dic_ = new Dictionary<GameObject, AbstractFreeModeItem>();
- private UIGrid grid_;
- private UIScrollView scroll_view_;
- private UIWFTabPanel tab_pabel_;
- private UILabel info_label_;
- private List<UILabel> condition_label_list_ = new List<UILabel>();
- private AbstractFreeModeItem select_item_data_;
- }
|