3 [
Attribute(
"Date_Date",
desc:
"Widget filled with date. At least Date or Day widget needs to be assigned for this UI to function")]
4 protected string m_sDateTextName;
6 [
Attribute(
"Date_Day",
desc:
"Widget filled with current day (Monday to Sunday). At least Date or Day widget needs to be assigned for this UI to function")]
7 protected string m_sDayTextName;
9 [
Attribute(
"1",
desc:
"If true month will be written in full text, else month will be a number")]
10 protected bool m_bMonthAsText;
12 [
Attribute(
"2",
desc:
"Time until the UI will update in seconds")]
13 protected float m_fUpdateFreq;
15 protected int m_iDayLastCheckedYear = -1;
16 protected int m_iDayLastCheckedMonth = -1;
17 protected int m_iDayLastCheckedDay = -1;
20 protected TextWidget m_DateText;
21 protected TextWidget m_DayText;
22 protected TimeAndWeatherManagerEntity m_TimeAndWeatherManagerEntity;
25 protected void UpdateIngameDate()
28 m_TimeAndWeatherManagerEntity.GetDate(year, month, day);
34 m_DateText.SetText(date);
39 if (m_iDayLastCheckedDay != day || m_iDayLastCheckedMonth != month || m_iDayLastCheckedYear != year)
41 m_iDayLastCheckedDay = day;
42 m_iDayLastCheckedMonth = month;
43 m_iDayLastCheckedYear = year;
45 m_DayText.SetText(m_TimeAndWeatherManagerEntity.GetWeekDayString());
51 override void HandlerAttached(Widget w)
56 m_DateText = TextWidget.Cast(w.FindAnyWidget(m_sDateTextName));
57 m_DayText = TextWidget.Cast(w.FindAnyWidget(m_sDayTextName));
59 if (!m_DateText && !m_DayText)
61 Print(
"'SCR_IngameDateUIComponent' is missing both date and day widget and therefore won't function", LogLevel.ERROR);
66 m_TimeAndWeatherManagerEntity = world.GetTimeAndWeatherManager();
67 if (!m_TimeAndWeatherManagerEntity)
69 Print(
"'SCR_IngameDateUIComponent' could not find the TimeAndWeatherManager", LogLevel.ERROR);
74 GetGame().GetCallqueue().CallLater(UpdateIngameDate, m_fUpdateFreq * 1000,
true);
77 override void HandlerDeattached(Widget w)
79 if (m_TimeAndWeatherManagerEntity)
80 GetGame().GetCallqueue().Remove(UpdateIngameDate);