Elin Decompiled Documentation EA 23.102 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 Image imageHour;
34
36
37 public Extra extra => base.config.extra as Extra;
38
39 public override object CreateExtra()
40 {
41 return new Extra();
42 }
43
44 public override void OnActivate()
45 {
46 Instance = this;
47 _Refresh();
48 InvokeRepeating("_Refresh", 0.1f, 0.1f);
49 }
50
51 public void _Refresh()
52 {
53 if (EMono.game.activeZone == null)
54 {
55 return;
56 }
57 string text = "";
58 GameDate date = EMono.world.date;
59 text += (extra.date ? EMono.world.date.GetText(Date.TextFormat.Widget) : "");
60 if (extra.period)
61 {
62 text = text + " (" + EMono.world.date.periodOfDay.ToString().lang() + ") ";
63 }
64 text += (extra.realDate ? (" (" + DateTime.Now.ToString("H:mm") + ") ") : "");
65 if (extra.loc)
66 {
67 text = text + " " + EMono._zone.NameWithLevel;
69 {
70 text += "(";
71 List<Element> list = EMono._zone.ListLandFeats();
72 foreach (Element item in list)
73 {
74 if (item != list[0])
75 {
76 text += ", ";
77 }
78 text += item.Name;
79 }
80 text += ")";
81 }
82 }
83 if (EMono._zone.idCurrentSubset != null)
84 {
85 text += ("(" + (EMono._zone.idExport + "_" + EMono._zone.idCurrentSubset).lang() + ")").TagColor(colorFestival);
86 }
88 {
89 text += "zone_peace".lang().TagColor(colorFestival);
90 }
92 {
93 text = text + " (" + EMono._zone.biome.name + "/Lv:" + EMono._zone.lv + "/Danger:" + EMono._zone.DangerLv + "/_danger:" + EMono._zone._dangerLv + "/elec:" + EMono._zone.electricity + ")";
95 {
96 text += "Instance";
97 }
98 }
99 if (extra.weather)
100 {
101 text = text + " - " + EMono.world.weather.GetName();
102 }
104 {
105 Room room = EMono.pc.Cell.room;
106 if (room != null)
107 {
108 text = text + " (" + room.Name + ")";
109 }
110 if (EMono.pc.pos.area != null)
111 {
112 text = text + " (" + EMono.pc.pos.area.Name + ")";
113 }
114 }
115 text += EMono._zone.TextWidgetDate;
116 foreach (ZoneEvent item2 in EMono._zone.events.list)
117 {
118 text += item2.TextWidgetDate;
119 }
120 if (EMono.Branch != null && EMono.Branch.luckyMonth)
121 {
122 text = text + " " + "lucky_month".lang().TagColor(Msg.colors.colors["save"]);
123 }
124 if (EMono.debug.enable)
125 {
126 text += " *DEBUG MODE*";
127 }
128 textTime.text = text;
129 rectClock.SetActive(extra.clock);
130 if (extra.clock)
131 {
132 imageHour.transform.localEulerAngles = new Vector3(0f, 0f, -date.hour * 30 + 90);
133 }
134 _ = base.transform.position.x / (float)Screen.width;
135 bool flag = base.config.pivot == RectPosition.BottomRIGHT || base.config.pivot == RectPosition.TopRIGHT || base.config.pivot == RectPosition.Right;
136 this.Rect().SetPivot(flag ? 1 : 0, 0f);
137 rectClock.SetAnchor(flag ? 1 : 0, 1f, flag ? 1 : 0, 1f);
138 rectClock.anchoredPosition = new Vector2(flag ? (-60) : 60, -75f);
139 textTime.RebuildLayout();
140 }
141
142 public override void OnChangePivot()
143 {
144 _Refresh();
145 }
146
147 public static void Refresh()
148 {
149 if ((bool)Instance)
150 {
152 }
153 }
154
155 public override void OnSetContextMenu(UIContextMenu m)
156 {
157 UIContextMenu uIContextMenu = m.AddChild("setting");
158 uIContextMenu.AddToggle("showPeriodOfDay", extra.period, delegate(bool a)
159 {
160 extra.period = a;
161 _Refresh();
162 });
163 uIContextMenu.AddToggle("showRealDate", extra.realDate, delegate(bool a)
164 {
165 extra.realDate = a;
166 _Refresh();
167 });
168 uIContextMenu.AddToggle("showRoom", extra.room, delegate(bool a)
169 {
170 extra.room = a;
171 _Refresh();
172 });
173 uIContextMenu.AddToggle("showClock", extra.clock, delegate(bool a)
174 {
175 extra.clock = a;
176 _Refresh();
177 });
178 uIContextMenu.AddToggle("showLoc", extra.loc, delegate(bool a)
179 {
180 extra.loc = a;
181 _Refresh();
182 });
183 uIContextMenu.AddToggle("showWeather", extra.weather, delegate(bool a)
184 {
185 extra.weather = a;
186 _Refresh();
187 });
189 }
190}
RectPosition
Definition: RectPosition.cs:2
Point pos
Definition: Card.cs:55
Cell Cell
Definition: Card.cs:1931
Room room
Definition: Cell.cs:102
bool IsInActiveZone
Definition: Chara.cs:791
bool showExtra
Definition: CoreDebug.cs:167
bool enable
Definition: CoreDebug.cs:285
Definition: Date.cs:4
PeriodOfDay periodOfDay
Definition: Date.cs:124
string GetText(TextFormat format)
Definition: Date.cs:245
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
Zone activeZone
Definition: Game.cs:245
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:548
bool isPeace
Definition: Spatial.cs:406
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
string GetName()
Definition: Weather.cs:158
Text textTime
Definition: WidgetDate.cs:27
Color colorFestival
Definition: WidgetDate.cs:35
override void OnSetContextMenu(UIContextMenu m)
Definition: WidgetDate.cs:155
override void OnChangePivot()
Definition: WidgetDate.cs:142
RectTransform rectClock
Definition: WidgetDate.cs:31
static void Refresh()
Definition: WidgetDate.cs:147
static WidgetDate Instance
Definition: WidgetDate.cs:25
Extra extra
Definition: WidgetDate.cs:37
Image imageHour
Definition: WidgetDate.cs:33
void _Refresh()
Definition: WidgetDate.cs:51
override object CreateExtra()
Definition: WidgetDate.cs:39
override void OnActivate()
Definition: WidgetDate.cs:44
Text textLevel
Definition: WidgetDate.cs:29
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608
GameDate date
Definition: World.cs:6
Weather weather
Definition: World.cs:12
List< ZoneEvent > list
virtual string TextWidgetDate
Definition: ZoneEvent.cs:25
ZoneEventManager events
Definition: Zone.cs:40
virtual string TextWidgetDate
Definition: Zone.cs:132
bool IsInstance
Definition: Zone.cs:480
List< Element > ListLandFeats()
Definition: Zone.cs:2834
bool IsPCFaction
Definition: Zone.cs:464
string NameWithLevel
Definition: Zone.cs:422