Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
MsgBox.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5using UnityEngine.UI;
6
7public class MsgBox : MonoBehaviour
8{
9 [Serializable]
10 public class Prefabs
11 {
13
14 public MsgLine line;
15
16 public UIText text;
17
18 public Transform image;
19
21 }
22
23 public VerticalLayoutGroup layout;
24
25 public VerticalLayoutGroup layoutLog;
26
27 public GameObject goLog;
28
29 public GameObject goBox;
30
32
33 public Image imageBg;
34
36
37 public int maxBlock;
38
39 public int maxLog;
40
41 public bool reverseOrder;
42
43 public bool multiLine;
44
45 public bool fadeLines;
46
47 private SpriteAsset bg;
48
49 private Color bgColor;
50
51 [NonSerialized]
52 public bool newblock;
53
54 [NonSerialized]
55 public bool isShowingLog;
56
57 [NonSerialized]
59
60 [NonSerialized]
61 public List<MsgBlock> blocks = new List<MsgBlock>();
62
63 [NonSerialized]
64 public List<MsgBlock> logs = new List<MsgBlock>();
65
66 public float maxWidth => this.Rect().rect.width / BaseCore.Instance.uiScale;
67
68 public void Init()
69 {
70 goLog.SetActive(value: false);
71 isShowingLog = false;
72 }
73
74 public void Append(string s, Color col)
75 {
77 currentBlock.Append(s, col);
78 }
79
80 public void Append(Sprite s, bool fitLine = false)
81 {
83 currentBlock.Append(s, fitLine);
84 }
85
86 public UIItem Load(string id)
87 {
89 return currentBlock.Load(id);
90 }
91
92 public void CreateNewBlock()
93 {
95 currentBlock.box = this;
96 currentBlock.bg.sprite = bg.sprite;
97 currentBlock.bg.Rect().sizeDelta = bg.size;
98 currentBlock.bg.color = bgColor;
100 newblock = false;
101 if (reverseOrder)
102 {
103 currentBlock.transform.SetAsFirstSibling();
104 }
105 blocks.Add(currentBlock);
106 if (blocks.Count > maxBlock)
107 {
108 int num = blocks.Count - maxBlock;
109 for (int i = 0; i < num; i++)
110 {
111 AddLog();
112 }
113 }
114 if (isShowingLog)
115 {
116 currentBlock.transform.SetParent(layoutLog.transform, worldPositionStays: false);
117 Image image = currentBlock.bg;
118 bool flag2 = (currentBlock.cg.enabled = false);
119 image.enabled = flag2;
120 }
121 else
122 {
123 Image image2 = currentBlock.bg;
124 bool flag2 = (currentBlock.cg.enabled = true);
125 image2.enabled = flag2;
126 RefreshAlpha();
127 }
128 }
129
130 private void SetCurrentBlock()
131 {
133 {
135 }
136 }
137
138 public void MarkNewBlock()
139 {
140 newblock = true;
141 }
142
143 public void RefreshAlpha()
144 {
145 for (int i = 0; i < blocks.Count; i++)
146 {
147 float alpha = 1f;
148 if (fadeLines && blocks.Count >= 3)
149 {
150 switch (i)
151 {
152 case 1:
153 alpha = 0.8f;
154 break;
155 case 0:
156 alpha = 0.65f;
157 break;
158 }
159 }
160 blocks[i].cg.alpha = alpha;
161 }
162 }
163
164 public void SetBG(SpriteAsset s, Color c)
165 {
166 bg = s;
167 bgColor = c;
168 foreach (MsgBlock item in blocks.Concat(logs))
169 {
170 item.bg.sprite = bg.sprite;
171 item.bg.color = bgColor;
172 item.bg.Rect().sizeDelta = bg.size;
173 }
174 }
175
176 public void Clear()
177 {
178 foreach (MsgBlock block in blocks)
179 {
181 }
182 foreach (MsgBlock log in logs)
183 {
184 PoolManager.Despawn(log);
185 }
186 blocks.Clear();
187 logs.Clear();
188 currentBlock = null;
189 newblock = false;
190 }
191
192 public void AddLog()
193 {
194 MsgBlock msgBlock = blocks[0];
195 blocks.RemoveAt(0);
196 logs.Add(msgBlock);
197 if (!isShowingLog)
198 {
199 msgBlock.transform.SetParent(layoutLog.transform, worldPositionStays: false);
200 }
201 if (logs.Count > maxLog)
202 {
203 msgBlock = logs[0];
204 logs.RemoveAt(0);
205 PoolManager.Despawn(msgBlock);
206 }
207 }
208
209 public void ToggleLog()
210 {
212 }
213
214 public void ToggleLog(bool show)
215 {
216 isShowingLog = show;
217 goBox.SetActive(!show);
218 goLog.SetActive(show);
219 if (show)
220 {
221 foreach (MsgBlock block in blocks)
222 {
223 block.transform.SetParent(layoutLog.transform, worldPositionStays: false);
224 }
225 MsgBlock[] componentsInChildren = layoutLog.GetComponentsInChildren<MsgBlock>();
226 foreach (MsgBlock msgBlock in componentsInChildren)
227 {
228 CanvasGroup cg = msgBlock.cg;
229 bool flag2 = (msgBlock.bg.enabled = false);
230 cg.enabled = flag2;
231 }
232 return;
233 }
234 foreach (MsgBlock block2 in blocks)
235 {
236 block2.transform.SetParent(layout.transform, worldPositionStays: false);
237 CanvasGroup cg2 = block2.cg;
238 bool flag2 = (block2.bg.enabled = true);
239 cg2.enabled = flag2;
240 }
241 RefreshAlpha();
242 layout.RebuildLayout();
243 }
244}
virtual float uiScale
Definition: BaseCore.cs:46
static BaseCore Instance
Definition: BaseCore.cs:11
int countElements
Definition: MsgBlock.cs:11
void Reset()
Definition: MsgBlock.cs:86
Image bg
Definition: MsgBlock.cs:13
UIItem Load(string id)
Definition: MsgBlock.cs:63
void Append(string s, Color col)
Definition: MsgBlock.cs:35
CanvasGroup cg
Definition: MsgBlock.cs:17
Transform image
Definition: MsgBox.cs:18
MsgLine line
Definition: MsgBox.cs:14
MsgBlock block
Definition: MsgBox.cs:12
UIButton button
Definition: MsgBox.cs:20
UIText text
Definition: MsgBox.cs:16
Definition: MsgBox.cs:8
bool reverseOrder
Definition: MsgBox.cs:41
Image imageBg
Definition: MsgBox.cs:33
bool fadeLines
Definition: MsgBox.cs:45
void Append(Sprite s, bool fitLine=false)
Definition: MsgBox.cs:80
List< MsgBlock > logs
Definition: MsgBox.cs:64
void ToggleLog(bool show)
Definition: MsgBox.cs:214
void Init()
Definition: MsgBox.cs:68
void Clear()
Definition: MsgBox.cs:176
void SetBG(SpriteAsset s, Color c)
Definition: MsgBox.cs:164
void AddLog()
Definition: MsgBox.cs:192
void Append(string s, Color col)
Definition: MsgBox.cs:74
bool multiLine
Definition: MsgBox.cs:43
UIDragPanel dragPanel
Definition: MsgBox.cs:35
VerticalLayoutGroup layoutLog
Definition: MsgBox.cs:25
int maxLog
Definition: MsgBox.cs:39
void SetCurrentBlock()
Definition: MsgBox.cs:130
List< MsgBlock > blocks
Definition: MsgBox.cs:61
int maxBlock
Definition: MsgBox.cs:37
bool isShowingLog
Definition: MsgBox.cs:55
void CreateNewBlock()
Definition: MsgBox.cs:92
bool newblock
Definition: MsgBox.cs:52
SpriteAsset bg
Definition: MsgBox.cs:47
float maxWidth
Definition: MsgBox.cs:66
VerticalLayoutGroup layout
Definition: MsgBox.cs:23
MsgBlock currentBlock
Definition: MsgBox.cs:58
Prefabs prefabs
Definition: MsgBox.cs:31
GameObject goLog
Definition: MsgBox.cs:27
void ToggleLog()
Definition: MsgBox.cs:209
GameObject goBox
Definition: MsgBox.cs:29
Color bgColor
Definition: MsgBox.cs:49
UIItem Load(string id)
Definition: MsgBox.cs:86
void RefreshAlpha()
Definition: MsgBox.cs:143
void MarkNewBlock()
Definition: MsgBox.cs:138
static void Despawn(Component c)
Definition: PoolManager.cs:128
static Transform Spawn(string id, string path, Transform parent)
Definition: PoolManager.cs:86
Vector2Int size
Definition: SpriteAsset.cs:11
Sprite sprite
Definition: SpriteAsset.cs:9
Definition: UIItem.cs:5
Definition: UIText.cs:6