Elin Modding Docs Doc
Loading...
Searching...
No Matches
BaseWidgetNotice.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x0200063A RID: 1594
7public class BaseWidgetNotice : Widget
8{
9 // Token: 0x06002CBD RID: 11453 RVA: 0x000FAF20 File Offset: 0x000F9120
10 public sealed override void OnActivate()
11 {
12 if (!this.mold)
13 {
14 this.mold = this.layout.CreateMold(null);
15 }
16 this._OnActivate();
17 this.RefreshLayout();
18 this.layout.RebuildLayout(true);
19 if (this.layout2)
20 {
21 this.layout2.RebuildLayout(true);
22 }
23 this.activating = false;
24 this._RefreshAll();
25 }
26
27 // Token: 0x06002CBE RID: 11454 RVA: 0x000FAF8A File Offset: 0x000F918A
28 public virtual void _OnActivate()
29 {
30 }
31
32 // Token: 0x06002CBF RID: 11455 RVA: 0x000FAF8C File Offset: 0x000F918C
33 private void OnEnable()
34 {
35 base.InvokeRepeating("_RefreshAll", 0.1f, 0.2f);
36 }
37
38 // Token: 0x06002CC0 RID: 11456 RVA: 0x000FAFA3 File Offset: 0x000F91A3
39 private void OnDisable()
40 {
41 base.CancelInvoke();
42 }
43
44 // Token: 0x06002CC1 RID: 11457 RVA: 0x000FAFAC File Offset: 0x000F91AC
45 public void _RefreshAll()
46 {
47 this.OnRefresh();
48 bool rebuild = false;
49 using (List<BaseNotification>.Enumerator enumerator = this.list.GetEnumerator())
50 {
51 while (enumerator.MoveNext())
52 {
53 BaseNotification n = enumerator.Current;
54 n.Refresh();
55 n.item.SetActive(n.Visible, delegate(bool enabled)
56 {
57 if (enabled)
58 {
59 n.item.button.RebuildLayout(true);
60 }
61 rebuild = true;
62 });
63 }
64 }
65 if (rebuild)
66 {
67 this.layout.RebuildLayout(false);
68 if (this.layout2)
69 {
70 this.layout2.RebuildLayout(true);
71 }
72 }
73 }
74
75 // Token: 0x06002CC2 RID: 11458 RVA: 0x000FB07C File Offset: 0x000F927C
76 public virtual void OnRefresh()
77 {
78 }
79
80 // Token: 0x06002CC3 RID: 11459 RVA: 0x000FB080 File Offset: 0x000F9280
81 public ItemNotice Add(BaseNotification n, Transform parent = null)
82 {
83 this.list.Add(n);
84 LayoutGroup layoutGroup = n.GetLayoutGroup() ?? this.layout;
85 ItemNotice itemNotice = Util.Instantiate<ItemNotice>(n.GetMold() ?? this.mold, parent ?? layoutGroup.transform);
86 itemNotice.button.onClick.AddListener(delegate()
87 {
88 if (EMono.scene.actionMode == ActionMode.NoMap)
89 {
90 BaseCore.Instance.WaitForEndOfFrame(new Action(n.OnClick));
91 return;
92 }
93 n.OnClick();
94 });
95 Sprite sprite = n.Sprite;
96 if (n.idSprite != -1)
97 {
98 sprite = this.sprites[n.idSprite];
99 }
100 if (sprite)
101 {
102 itemNotice.button.icon.sprite = sprite;
103 }
104 itemNotice.button.image.raycastTarget = n.Interactable;
105 itemNotice.button.tooltip.enable = (n.onShowTooltip != null);
106 itemNotice.button.tooltip.onShowTooltip = n.onShowTooltip;
107 n.item = itemNotice;
108 n.Refresh();
109 n.OnInstantiate();
110 if (!this.activating)
111 {
112 layoutGroup.RebuildLayout(true);
113 }
114 return itemNotice;
115 }
116
117 // Token: 0x06002CC4 RID: 11460 RVA: 0x000FB1CF File Offset: 0x000F93CF
118 public void Remove(BaseNotification n)
119 {
120 this.list.Remove(n);
121 if (n.item)
122 {
123 UnityEngine.Object.DestroyImmediate(n.item.gameObject);
124 }
125 }
126
127 // Token: 0x06002CC5 RID: 11461 RVA: 0x000FB1FC File Offset: 0x000F93FC
128 public override void OnFlip()
129 {
130 this.layout.childAlignment = (this.flip ? TextAnchor.MiddleRight : TextAnchor.MiddleLeft);
131 this.Rect().pivot = new Vector2((float)(this.flip ? 1 : 0), this.Rect().pivot.y);
132 }
133
134 // Token: 0x06002CC6 RID: 11462 RVA: 0x000FB250 File Offset: 0x000F9450
135 public override void OnSetContextMenu(UIContextMenu m)
136 {
137 m.AddChild("style").AddSlider("toggleButtonBG", (float a) => a.ToString() ?? "", (float)base.config.skin.button, delegate(float a)
138 {
139 base.config.skin.button = (int)a;
140 this.ApplySkin();
141 }, 0f, (float)(base.config.skin.Skin.buttons.Count - 1), true, true, false);
142 base.SetBaseContextMenu(m);
143 }
144
145 // Token: 0x06002CC7 RID: 11463 RVA: 0x000FB2DC File Offset: 0x000F94DC
146 public void RefreshLayout()
147 {
148 SkinAsset_Button button = base.GetComponent<SkinRoot>().Config.Button;
149 int y = button.size.y;
150 foreach (BaseNotification baseNotification in this.list)
151 {
152 RectTransform rectTransform = baseNotification.item.Rect();
153 rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, (float)y);
154 }
155 this.layout.spacing = (float)button.spacing.y;
156 }
157
158 // Token: 0x06002CC8 RID: 11464 RVA: 0x000FB37C File Offset: 0x000F957C
159 public override void OnApplySkin()
160 {
161 this.RefreshLayout();
162 }
163
164 // Token: 0x04001913 RID: 6419
165 public Sprite[] sprites;
166
167 // Token: 0x04001914 RID: 6420
168 public List<BaseNotification> list = new List<BaseNotification>();
169
170 // Token: 0x04001915 RID: 6421
171 public VerticalLayoutGroup layout;
172
173 // Token: 0x04001916 RID: 6422
174 public VerticalLayoutGroup layout2;
175
176 // Token: 0x04001917 RID: 6423
177 public ItemNotice mold;
178
179 // Token: 0x04001918 RID: 6424
180 private bool activating = true;
181}
Definition EMono.cs:6