using System; using System.Collections.Generic; using I2.Loc; using UnityEngine; using wf; [RequireComponent(typeof(UITable))] public class UIWFConditionList : MonoBehaviour { public int height { get; private set; } public int width { get; private set; } private void Awake() { if (this.condition_label_list_ != null) { return; } this.condition_label_list_ = new List(); this.condition_label_localize_list_ = new List(); UITable component = base.GetComponent(); List childList = component.GetChildList(); foreach (Transform transform in childList) { UILabel component2 = UTY.GetChildObject(transform.gameObject, "Message", false).GetComponent(); component2.overflowMethod = UILabel.Overflow.ShrinkContent; this.condition_label_list_.Add(component2); this.condition_label_localize_list_.Add(component2.GetComponent()); this.defaultFontSize = component2.fontSize; this.widthMargin = (int)(component2.transform.localPosition.x - (float)(UTY.GetChildObject(transform.gameObject, "No", false).GetComponent().width / -2)); transform.gameObject.SetActive(false); } } public void SetTexts(string[] texts, int limitTextWidth = -1) { KeyValuePair[] array = new KeyValuePair[texts.Length]; for (int i = 0; i < texts.Length; i++) { array[i] = new KeyValuePair(new string[] { texts[i] }, Color.white); } this.SetTexts(array, limitTextWidth); } public void SetTexts(KeyValuePair[] texts, int limitTextWidth = -1) { if (this.condition_label_list_ == null) { this.Awake(); } this.lastLimitTextWidth = limitTextWidth; float num = 0f; float num2 = 0f; Localize localize = null; for (int i = 0; i < this.condition_label_list_.Count; i++) { if (this.condition_label_localize_list_[i] != null) { this.condition_label_localize_list_[i].LocalizeEvent.RemoveAllListeners(); } if (i < texts.Length) { Transform parent = this.condition_label_list_[i].transform.parent; if (i == 0) { num = Mathf.Abs(parent.localPosition.y); } this.condition_label_list_[i].transform.parent.gameObject.SetActive(true); if (texts[i].Key.Length == 1) { if (!Product.supportMultiLanguage || this.condition_label_localize_list_[i] == null) { this.condition_label_list_[i].text = Utility.GetTermLastWord(texts[i].Key[0]); } else { this.condition_label_localize_list_[i].TermArgs = null; this.condition_label_localize_list_[i].SetTerm(string.Empty); this.condition_label_localize_list_[i].SetTerm(texts[i].Key[0]); } } else if (!Product.supportMultiLanguage || this.condition_label_localize_list_[i] == null) { string[] array = new string[texts[i].Key.Length - 1]; for (int j = 1; j < texts[i].Key.Length; j++) { array[j - 1] = Utility.GetTermLastWord(texts[i].Key[j]); } this.condition_label_list_[i].text = string.Format(Utility.GetTermLastWord(texts[i].Key[0]), array); } else { bool setIsTerm = false; if (texts[i].Key[0].Contains("性経験") || texts[i].Key[0].Contains("契約タイプ") || texts[i].Key[0].Contains("性癖") || texts[i].Key[0].Contains("ヒロインタイプ")) { setIsTerm = true; } Localize.ArgsPair[] array2 = new Localize.ArgsPair[texts[i].Key.Length - 1]; for (int k = 1; k < texts[i].Key.Length; k++) { array2[k - 1] = Localize.ArgsPair.Create(texts[i].Key[k], setIsTerm); } this.condition_label_localize_list_[i].TermArgs = array2; this.condition_label_localize_list_[i].SetTerm(texts[i].Key[0]); localize = this.condition_label_localize_list_[i]; } this.condition_label_list_[i].color = texts[i].Value; num2 = Mathf.Abs(parent.localPosition.y) + (float)parent.gameObject.GetComponent().height; } else { this.condition_label_list_[i].transform.parent.gameObject.SetActive(false); } } this.height = (int)(num2 - num); this.ResizeUI(limitTextWidth); if (localize != null) { localize.LocalizeEvent.AddListener(delegate() { this.updateFlag = true; }); } } private void Update() { if (!this.updateFlag) { return; } this.ResizeUI(this.lastLimitTextWidth); this.updateFlag = false; } public void ResizeUI(int limitTextWidth = -1) { this.width = 0; for (int i = 0; i < this.condition_label_list_.Count; i++) { if (this.condition_label_list_[i].transform.parent.gameObject.activeSelf) { if (limitTextWidth != -1) { this.condition_label_list_[i].width = limitTextWidth; } else { this.condition_label_list_[i].fontSize = this.defaultFontSize; this.condition_label_list_[i].width = 0; this.condition_label_list_[i].MakePixelPerfect(); if (0 <= limitTextWidth) { Utility.ResizeUILabelFontSize(this.condition_label_list_[i], limitTextWidth); } this.width = Mathf.Max(this.width, this.condition_label_list_[i].width); } } } this.width += this.widthMargin; if (this.resizeUIEvent != null && this.resizeUIEvent.Count >= 1) { EventDelegate.Execute(this.resizeUIEvent); } } private int widthMargin; public List resizeUIEvent = new List(); private int lastLimitTextWidth = -1; private bool updateFlag; private List condition_label_list_; private List condition_label_localize_list_; private int defaultFontSize; }