Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetMainText.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3
4public class WidgetMainText : Widget
5{
6 public class Extra
7 {
8 public int maxLine;
9
10 public int bg;
11
12 public int width;
13
14 public bool fadeLines;
15 }
16
17 public static WidgetMainText Instance;
18
19 public static MsgBox boxBk;
20
21 public static bool ignoreStack;
22
23 public MsgBox box;
24
26
28
29 public int visibleLines;
30
31 public Transform layout;
32
33 public Sprite spriteElin;
34
35 public Sprite spriteDestroy;
36
37 public Sprite spriteEther;
38
39 [NonSerialized]
40 public bool newLine = true;
41
42 public Extra extra => base.config.extra as Extra;
43
44 public override bool ShowStyleMenu => false;
45
46 public override bool AlwaysTop => true;
47
48 public override object CreateExtra()
49 {
50 return new Extra();
51 }
52
53 public override void OnActivate()
54 {
55 bool flag = true;
56 if ((bool)boxBk)
57 {
58 UnityEngine.Object.DestroyImmediate(box.gameObject);
59 box = boxBk;
60 boxBk.transform.SetParent(base.transform, worldPositionStays: false);
61 boxBk.GetComponentInChildren<UIDragPanel>(includeInactive: true).SetTarget(this.Rect());
62 boxBk = null;
63 flag = false;
64 }
67 Instance = this;
68 box.maxBlock = extra.maxLine;
69 box.fadeLines = extra.fadeLines;
70 if (base.config.skin.bgColor.Equals(new Color(0f, 0f, 0f, 0f)))
71 {
72 base.config.skin.bgColor = EMono.core.refs.bg_msg[extra.bg].color;
73 }
74 RefreshBG();
76 box.Init();
77 if (flag)
78 {
79 Append("welcome_intro".langGame(EMono.core.version.GetText()));
81 NewLine();
82 Append("welcome".langGame(EInput.keys.report.key.ToString() ?? ""));
83 NewLine();
84 }
85 _Refresh();
86 }
87
88 public void RefreshBG()
89 {
90 box.SetBG(EMono.core.refs.bg_msg[extra.bg], base.config.skin.bgColor);
91 }
92
93 public void Append(string s, Point pos = null)
94 {
95 Append(s, Msg.colors.Default, pos);
96 }
97
98 public void Append(string s, Color col, Point pos = null)
99 {
100 if (s.IsEmpty() || s == " ")
101 {
102 return;
103 }
104 if (pos != null)
105 {
106 box.Load("MsgFocus").button1.onClick.AddListener(delegate
107 {
108 EMono.screen.Focus(pos);
109 });
110 }
111 if (s.StartsWith("*"))
112 {
113 s = " " + s;
114 }
116 {
117 s += " ";
118 if (s[0] == ' ')
119 {
120 s = s.TrimStart(' ');
121 }
122 }
123 else if (s.EndsWith("*"))
124 {
125 s += " ";
126 }
127 if (MsgBlock.lastBlock != null && MsgBlock.lastText == s && !ignoreStack)
128 {
129 MsgBlock lastBlock = MsgBlock.lastBlock;
130 if (lastBlock.txt != null)
131 {
132 UIText txt = lastBlock.txt;
133 lastBlock.repeat++;
134 string text = txt.text;
135 if (text.EndsWith(") ") && text.Contains("(x"))
136 {
137 text = text.Substring(0, text.IndexOf("(x"));
138 }
139 txt.text = text + "(x" + (lastBlock.repeat + 1) + ") ";
140 if (lastBlock.repeat == 1)
141 {
142 txt.RebuildLayout();
143 box.RebuildLayout(recursive: true);
144 }
145 return;
146 }
147 }
148 box.Append(s, col);
149 _Refresh();
150 }
151
152 public void Append(Sprite sprite)
153 {
154 box.Append(sprite);
155 _Refresh();
156 }
157
158 public static void HideLog()
159 {
160 if ((bool)Instance && Instance.box.isShowingLog)
161 {
163 }
164 }
165
166 public static void ToggleLog()
167 {
168 if (!Instance)
169 {
170 EMono.ui.widgets.Activate("MainText");
171 }
173 SE.ClickGeneral();
174 }
175
176 public void _ToggleLog()
177 {
178 box.ToggleLog();
179 _Refresh();
180 if (box.isShowingLog)
181 {
182 if ((bool)WidgetFeed.Instance)
183 {
185 }
186 box.RebuildLayout(recursive: true);
187 }
188 }
189
190 public void NewLine()
191 {
193 }
194
195 public static void Refresh()
196 {
197 if ((bool)Instance)
198 {
200 }
201 }
202
203 private void _Refresh()
204 {
205 box.SetActive(box.isShowingLog || !WidgetFeed.Intercept, delegate(bool enabled)
206 {
207 if (enabled)
208 {
209 box.RebuildLayout(recursive: true);
210 }
211 });
212 }
213
214 public override void OnSetContextMenu(UIContextMenu m)
215 {
216 SkinConfig cfg = base.config.skin;
217 UIContextMenu uIContextMenu = m.AddChild("setting");
218 uIContextMenu.AddSlider("msgLines", (float n) => n.ToString() ?? "", box.maxBlock, delegate(float a)
219 {
220 box.maxBlock = (int)a;
221 extra.maxLine = (int)a;
222 }, 2f, 10f, isInt: true, hideOther: false);
223 uIContextMenu.AddSlider("width", (float a) => a.ToString() ?? "", extra.width, delegate(float a)
224 {
225 extra.width = (int)a;
227 }, 30f, 100f, isInt: true);
228 UIContextMenu uIContextMenu2 = m.AddChild("style");
229 uIContextMenu2.AddToggle("fadeLines", extra.fadeLines, delegate(bool a)
230 {
231 extra.fadeLines = (box.fadeLines = a);
233 });
234 uIContextMenu2.AddSlider("changeBG", (float n) => n + "/" + (EMono.core.refs.bg_msg.Count - 1), extra.bg, delegate(float a)
235 {
236 extra.bg = (int)a;
237 cfg.bgColor = EMono.core.refs.bg_msg[extra.bg].color;
238 RefreshBG();
239 }, 0f, EMono.core.refs.bg_msg.Count - 1, isInt: true);
240 uIContextMenu2.AddButton("colorBG", delegate
241 {
242 EMono.ui.AddLayer<LayerColorPicker>().SetColor(cfg.bgColor, EMono.ui.skins.skinSets[cfg.id].bgs[cfg.bg].color, delegate(PickerState state, Color _c)
243 {
244 cfg.bgColor = _c;
245 RefreshBG();
246 });
247 });
249 }
250
251 public override void OnChangeResolution()
252 {
253 base.OnChangeResolution();
254 RectTransform rectTransform = this.Rect();
255 rectTransform.sizeDelta = new Vector2(0.01f * (float)Screen.width * (float)extra.width, rectTransform.sizeDelta.y);
256 }
257}
PickerState
Definition: PickerState.cs:2
Version version
Definition: BaseCore.cs:17
void Focus(Int3 ints)
List< SpriteAsset > bg_msg
Definition: CoreRef.cs:353
CoreRef refs
Definition: Core.cs:51
KeyCode key
Definition: EInput.cs:14
Definition: EInput.cs:8
static KeyMapManager keys
Definition: EInput.cs:367
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static BaseGameScreen screen
Definition: EMono.cs:29
static UI ui
Definition: EMono.cs:15
bool useSpace
Definition: LangSetting.cs:36
Definition: Lang.cs:6
static LangSetting setting
Definition: Lang.cs:54
static MsgBlock lastBlock
Definition: MsgBlock.cs:7
int repeat
Definition: MsgBlock.cs:28
static string lastText
Definition: MsgBlock.cs:9
UIText txt
Definition: MsgBlock.cs:25
Definition: MsgBox.cs:8
Image imageBg
Definition: MsgBox.cs:33
void Init()
Definition: MsgBox.cs:68
void SetBG(SpriteAsset s, Color c)
Definition: MsgBox.cs:164
void Append(string s, Color col)
Definition: MsgBox.cs:74
UIDragPanel dragPanel
Definition: MsgBox.cs:35
int maxBlock
Definition: MsgBox.cs:37
bool isShowingLog
Definition: MsgBox.cs:55
void ToggleLog()
Definition: MsgBox.cs:209
UIItem Load(string id)
Definition: MsgBox.cs:86
void RefreshAlpha()
Definition: MsgBox.cs:143
void MarkNewBlock()
Definition: MsgBox.cs:138
Color Default
Definition: MsgColors.cs:5
Definition: Msg.cs:5
static MsgColors colors
Definition: Msg.cs:20
Definition: Point.cs:9
void KillAll(bool instant=false)
Definition: PopManager.cs:213
Color bgColor
Definition: SkinConfig.cs:67
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)
void AddButton(Func< string > funcText, UnityAction action=null)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
Definition: UIItem.cs:5
UIButton button1
Definition: UIItem.cs:18
Definition: UIText.cs:6
static bool Intercept
Definition: WidgetFeed.cs:27
PopManager pop
Definition: WidgetFeed.cs:18
static WidgetFeed Instance
Definition: WidgetFeed.cs:14
void Append(Sprite sprite)
static WidgetMainText Instance
static void ToggleLog()
static void Refresh()
void Append(string s, Color col, Point pos=null)
override bool AlwaysTop
override void OnSetContextMenu(UIContextMenu m)
override void OnActivate()
static bool ignoreStack
override void OnChangeResolution()
void Append(string s, Point pos=null)
static void HideLog()
Transform layout
Sprite spriteDestroy
static MsgBox boxBk
override bool ShowStyleMenu
override object CreateExtra()
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608
UIDragPanel dragPanel
Definition: Widget.cs:154
Image imageBG
Definition: Widget.cs:150
string GetText()
Definition: Version.cs:16