123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class WindowPartsPopUpList : MonoBehaviour
- {
- public virtual void Awake()
- {
- EventDelegate.Add(this.PopupList.onChange, delegate()
- {
- if (this.onChangePopUpListValue == null || this.onChangePopUpListValue.Count <= 0)
- {
- return;
- }
- bool flag = false;
- KeyValuePair<string, UnityEngine.Object> obj = new KeyValuePair<string, UnityEngine.Object>(string.Empty, null);
- for (int j = 0; j < this.popup_value_list_.Count; j++)
- {
- if (this.popup_value_list_[j].Key == this.PopupList.value)
- {
- obj = this.popup_value_list_[j];
- flag = true;
- break;
- }
- }
- if (flag)
- {
- for (int k = 0; k < this.onChangePopUpListValue.Count; k++)
- {
- this.onChangePopUpListValue[k](obj);
- }
- }
- });
- this.init_popup_list_value_ = new List<string>(this.PopupList.items);
- this.popup_value_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
- for (int i = 0; i < this.init_popup_list_value_.Count; i++)
- {
- this.popup_value_list_.Add(new KeyValuePair<string, UnityEngine.Object>(this.init_popup_list_value_[i], null));
- }
- }
- public virtual bool SetPopupValue(string name)
- {
- this.PopupList.Close();
- for (int i = 0; i < this.popup_value_list_.Count; i++)
- {
- if (this.popup_value_list_[i].Key == name)
- {
- this.PopupList.value = name;
- return true;
- }
- }
- return false;
- }
- public KeyValuePair<string, UnityEngine.Object> popup_select_value
- {
- get
- {
- for (int i = 0; i < this.popup_value_list_.Count; i++)
- {
- if (this.popup_value_list_[i].Key == this.PopupList.value)
- {
- return this.popup_value_list_[i];
- }
- }
- if (0 < this.popup_value_list_.Count)
- {
- return this.popup_value_list_[0];
- }
- return new KeyValuePair<string, UnityEngine.Object>(string.Empty, null);
- }
- }
- public List<KeyValuePair<string, UnityEngine.Object>> popup_value_list
- {
- get
- {
- if (this.popup_value_list_ != null)
- {
- return new List<KeyValuePair<string, UnityEngine.Object>>(this.popup_value_list_);
- }
- return null;
- }
- set
- {
- this.popup_value_list_ = null;
- if (value != null)
- {
- this.popup_value_list_ = new List<KeyValuePair<string, UnityEngine.Object>>(value);
- }
- else
- {
- this.popup_value_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
- for (int i = 0; i < this.init_popup_list_value_.Count; i++)
- {
- this.popup_value_list_.Add(new KeyValuePair<string, UnityEngine.Object>(this.init_popup_list_value_[i], null));
- }
- }
- List<string> list = new List<string>();
- for (int j = 0; j < this.popup_value_list_.Count; j++)
- {
- list.Add(this.popup_value_list_[j].Key);
- }
- this.PopupList.items = list;
- }
- }
- public UIPopupList PopupList;
- public List<Action<KeyValuePair<string, UnityEngine.Object>>> onChangePopUpListValue = new List<Action<KeyValuePair<string, UnityEngine.Object>>>();
- private List<KeyValuePair<string, UnityEngine.Object>> popup_value_list_;
- private List<string> init_popup_list_value_;
- }
|