Elin Decompiled Documentation EA 23.259 Nightly
Loading...
Searching...
No Matches
WidgetDate.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class WidgetDate : Widget
7{
8 public class Extra
9 {
10 public bool date;
11
12 public bool realDate;
13
14 public bool period;
15
16 public bool room;
17
18 public bool clock;
19
20 public bool loc;
21
22 public bool weather;
23 }
24
25 public static WidgetDate Instance;
26
27 public Text textTime;
28
29 public Text textLevel;
30
31 public RectTransform rectClock;
32
33 public RectTransform rectFieldEffect;
34
35 public GridLayoutGroup gridFieldEffect;
36
37 public Image imageHour;
38
40
42
43 public Extra extra => base.config.extra as Extra;
44
45 public override object CreateExtra()
46 {
47 return new Extra();
48 }
49
50 public override void OnActivate()
51 {
52 Instance = this;
53 _Refresh();
54 InvokeRepeating("_Refresh", 0.1f, 0.1f);
55 }
56
57 public void _Refresh()
58 {
59 if (EMono.game.activeZone == null)
60 {
61 return;
62 }
63 string text = "";
64 GameDate date = EMono.world.date;
65 text += (extra.date ? EMono.world.date.GetText(Date.TextFormat.Widget) : "");
66 if (extra.period)
67 {
68 text = text + " (" + EMono.world.date.periodOfDay.ToString().lang() + ") ";
69 }
70 text += (extra.realDate ? (" (" + DateTime.Now.ToString("H:mm") + ") ") : "");
71 if (extra.loc)
72 {
73 text = text + " " + EMono._zone.NameWithLevel;
75 {
76 text += EMono._zone.TextDangerLv;
77 }
79 {
80 text += "(";
81 List<Element> list = EMono._zone.ListLandFeats();
82 foreach (Element item in list)
83 {
84 if (item != list[0])
85 {
86 text += ", ";
87 }
88 text += item.Name;
89 }
90 text += ")";
91 }
92 }
93 if (EMono._zone.idCurrentSubset != null)
94 {
95 text += ("(" + (EMono._zone.idExport + "_" + EMono._zone.idCurrentSubset).lang() + ")").TagColor(colorFestival);
96 }
98 {
99 text += "zone_peace".lang().TagColor(colorFestival);
100 }
102 {
103 text = text + " <size=12>(" + EMono._zone.biome.name + "/Lv:" + EMono._zone.lv + "/Danger:" + EMono._zone.DangerLv + "/_danger:" + EMono._zone._dangerLv + "/elec:" + EMono._zone.electricity + ")</size>";
105 {
106 text += "Instance";
107 }
108 }
109 if (extra.weather)
110 {
111 text = text + " - " + EMono.world.weather.GetName();
112 }
114 {
115 Room room = EMono.pc.Cell.room;
116 if (room != null)
117 {
118 text = text + " (" + room.Name + ")";
119 }
120 if (EMono.pc.pos.area != null)
121 {
122 text = text + " (" + EMono.pc.pos.area.Name + ")";
123 }
124 }
125 text += EMono._zone.TextWidgetDate;
126 foreach (ZoneEvent item2 in EMono._zone.events.list)
127 {
128 text += item2.TextWidgetDate;
129 }
131 {
132 text += "raid_till".lang(EMono.game.survival.flags.raidLv.ToString() ?? "");
133 }
134 if (EMono.Branch != null && EMono.Branch.luckyMonth)
135 {
136 text = text + " " + "lucky_month".lang().TagColor(Msg.colors.colors["save"]);
137 }
138 if (EMono.debug.enable)
139 {
140 text += " *DEBUG MODE*";
141 }
142 textTime.text = text;
143 rectClock.SetActive(extra.clock);
144 if (extra.clock)
145 {
146 imageHour.transform.localEulerAngles = new Vector3(0f, 0f, -date.hour * 30 + 90);
147 }
148 _ = base.transform.position.x / (float)Screen.width;
149 bool flag = base.config.pivot == RectPosition.BottomRIGHT || base.config.pivot == RectPosition.TopRIGHT || base.config.pivot == RectPosition.Right;
150 this.Rect().SetPivot(flag ? 1 : 0, 0f);
151 rectClock.SetAnchor(flag ? 1 : 0, 1f, flag ? 1 : 0, 1f);
152 rectClock.anchoredPosition = new Vector2(flag ? (-60) : 60, -75f);
153 rectFieldEffect.SetAnchor(flag ? 1 : 0, 1f, flag ? 1 : 0, 1f);
154 rectFieldEffect.anchoredPosition = new Vector2(flag ? (-120) : 120, -75f);
155 gridFieldEffect.startCorner = (flag ? GridLayoutGroup.Corner.UpperRight : GridLayoutGroup.Corner.UpperLeft);
156 gridFieldEffect.childAlignment = (flag ? TextAnchor.UpperRight : TextAnchor.UpperLeft);
157 foreach (UIButton componentsInDirectChild in gridFieldEffect.GetComponentsInDirectChildren<UIButton>())
158 {
159 if (!(componentsInDirectChild.refObj is FieldEffect fieldEffect) || fieldEffect.owner != EMono._zone.fieldElements || fieldEffect.Value == 9)
160 {
161 UnityEngine.Object.DestroyImmediate(componentsInDirectChild.gameObject);
162 }
163 }
164 foreach (Element e in EMono._zone.fieldElements.dict.Values)
165 {
166 FieldEffect f = e as FieldEffect;
167 if (f.button == null)
168 {
169 UIButton uIButton = Util.Instantiate(moldButtonFieldEffect, gridFieldEffect);
170 f.button = uIButton;
171 uIButton.refObj = e;
172 }
173 f.button.icon.sprite = f.GetSprite();
174 f.button.SetTooltip("note", delegate(UITooltip t)
175 {
176 e.WriteNote(t.note, EMono._zone.fieldElements, delegate
177 {
178 e._WriteNote(t.note, EMono.pc, f);
179 });
180 });
181 }
182 textTime.RebuildLayout();
183 }
184
185 public override void OnChangePivot()
186 {
187 _Refresh();
188 }
189
190 public static void Refresh()
191 {
192 if ((bool)Instance)
193 {
194 Instance._Refresh();
195 }
196 }
197
198 public override void OnSetContextMenu(UIContextMenu m)
199 {
200 UIContextMenu uIContextMenu = m.AddChild("setting");
201 uIContextMenu.AddToggle("showPeriodOfDay", extra.period, delegate(bool a)
202 {
203 extra.period = a;
204 _Refresh();
205 });
206 uIContextMenu.AddToggle("showRealDate", extra.realDate, delegate(bool a)
207 {
208 extra.realDate = a;
209 _Refresh();
210 });
211 uIContextMenu.AddToggle("showRoom", extra.room, delegate(bool a)
212 {
213 extra.room = a;
214 _Refresh();
215 });
216 uIContextMenu.AddToggle("showClock", extra.clock, delegate(bool a)
217 {
218 extra.clock = a;
219 _Refresh();
220 });
221 uIContextMenu.AddToggle("showLoc", extra.loc, delegate(bool a)
222 {
223 extra.loc = a;
224 _Refresh();
225 });
226 uIContextMenu.AddToggle("showWeather", extra.weather, delegate(bool a)
227 {
228 extra.weather = a;
229 _Refresh();
230 });
231 SetBaseContextMenu(m);
232 }
233}
RectPosition
Definition: RectPosition.cs:2
override Sprite GetSprite()
Definition: ACT.cs:193
Point pos
Definition: Card.cs:60
Cell Cell
Definition: Card.cs:2056
Room room
Definition: Cell.cs:102
bool IsInActiveZone
Definition: Chara.cs:840
bool showExtra
Definition: CoreDebug.cs:168
bool enable
Definition: CoreDebug.cs:286
Definition: Date.cs:4
PeriodOfDay periodOfDay
Definition: Date.cs:128
string GetText(TextFormat format)
Definition: Date.cs:249
TextFormat
Definition: Date.cs:6
Definition: EMono.cs:4
static Chara pc
Definition: EMono.cs:13
static World world
Definition: EMono.cs:37
static Zone _zone
Definition: EMono.cs:19
static Game game
Definition: EMono.cs:7
static FactionBranch Branch
Definition: EMono.cs:21
static CoreDebug debug
Definition: EMono.cs:45
Dictionary< int, Element > dict
void _WriteNote(UINote n, Chara c, Act act)
Definition: ELEMENT.cs:611
void WriteNote(UINote n, ElementContainer owner=null, Action< UINote > onWriteNote=null)
Definition: ELEMENT.cs:589
UIButton button
Definition: FieldEffect.cs:3
SurvivalManager survival
Definition: Game.cs:228
Zone activeZone
Definition: Game.cs:252
bool IsSurvival
Definition: Game.cs:276
UD_String_Color colors
Definition: MsgColors.cs:23
Definition: Msg.cs:5
static MsgColors colors
Definition: Msg.cs:20
Area area
Definition: Point.cs:73
Definition: Room.cs:4
string idCurrentSubset
Definition: Spatial.cs:28
virtual bool isClaimable
Definition: Spatial.cs:562
bool isPeace
Definition: Spatial.cs:406
void SetTooltip(Action< UITooltip > onShowTooltip=null, bool enable=true)
Definition: UIButton.cs:361
object refObj
Definition: UIButton.cs:151
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
UINote note
Definition: UITooltip.cs:21
string GetName()
Definition: Weather.cs:158
RectTransform rectFieldEffect
Definition: WidgetDate.cs:33
Text textTime
Definition: WidgetDate.cs:27
Color colorFestival
Definition: WidgetDate.cs:39
override void OnSetContextMenu(UIContextMenu m)
Definition: WidgetDate.cs:198
override void OnChangePivot()
Definition: WidgetDate.cs:185
RectTransform rectClock
Definition: WidgetDate.cs:31
static void Refresh()
Definition: WidgetDate.cs:190
static WidgetDate Instance
Definition: WidgetDate.cs:25
Extra extra
Definition: WidgetDate.cs:43
Image imageHour
Definition: WidgetDate.cs:37
UIButton moldButtonFieldEffect
Definition: WidgetDate.cs:41
void _Refresh()
Definition: WidgetDate.cs:57
override object CreateExtra()
Definition: WidgetDate.cs:45
GridLayoutGroup gridFieldEffect
Definition: WidgetDate.cs:35
override void OnActivate()
Definition: WidgetDate.cs:50
Text textLevel
Definition: WidgetDate.cs:29
Definition: Widget.cs:7
GameDate date
Definition: World.cs:6
Weather weather
Definition: World.cs:12
List< ZoneEvent > list
virtual string TextWidgetDate
Definition: ZoneEvent.cs:25
string TextDangerLv
Definition: Zone.cs:431
ZoneEventManager events
Definition: Zone.cs:40
ElementContainerField fieldElements
Definition: Zone.cs:46
virtual string TextWidgetDate
Definition: Zone.cs:135
bool IsInstance
Definition: Zone.cs:489
List< Element > ListLandFeats()
Definition: Zone.cs:3115
bool IsPCFaction
Definition: Zone.cs:473
string NameWithLevel
Definition: Zone.cs:429