4 [
Attribute(
"Time",
desc:
"Clock needs at least the Time icon, time multiplier or Time Text to function")]
5 protected string m_sTimeTextName;
7 [
Attribute(
"DayTime_Icon",
desc:
"Clock needs at least the Time icon, time multiplier or Time Text to function")]
8 protected string m_sTimeIconName;
10 [
Attribute(
"Time_Multiplier",
desc:
"Clock needs at least the Time icon, time multiplier or Time Text to function")]
11 protected string m_sTimeMultiplierName;
13 [
Attribute(
"#AR-ValueUnit_Short_Multiplier", uiwidget: UIWidgets.LocaleEditBox)]
14 protected string m_sTimeMultiplierFormat;
16 [
Attribute(
"#AR-Weather_Forecast_NoTimeProgression", uiwidget: UIWidgets.LocaleEditBox)]
17 protected string m_sNoTimeProgression;
19 [
Attribute(
"1",
desc:
"Time until the UI will update in seconds")]
20 protected float m_fUpdateFreq;
22 [
Attribute(
"1",
desc:
"If true will hide the time multiplier if one (and assigned)")]
23 protected bool m_bHideTimeMultiplierIfOne;
25 [
Attribute(
desc:
"If the current time of day is in this Phase show moonphase instead of daytimeIcon", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EDayTimeEnums))]
26 protected ref array<EDayTimeEnums> m_aShowMoonphaseAtDayTimes;
29 protected TextWidget m_TimeText;
30 protected ImageWidget m_TimeIcon;
31 protected TextWidget m_TimeMultiplier;
32 protected TimeAndWeatherManagerEntity m_TimeAndWeatherManagerEntity;
37 protected void UpdateIngameClock()
42 int hour, minute, sec;
43 m_TimeAndWeatherManagerEntity.GetHoursMinutesSeconds(hour, minute, sec);
44 m_TimeText.SetTextFormat(
SCR_FormatHelper.GetTimeFormattingHoursMinutes(hour, minute));
50 EDayTimeEnums dayTimePhase = m_TimeAndWeatherManagerEntity.GetCurrentDayTimeUIInfoAndPhase(dayTimeUIInfo);
52 if (m_aShowMoonphaseAtDayTimes.Contains(dayTimePhase))
54 SCR_MoonPhaseUIInfo moonPhase = m_TimeAndWeatherManagerEntity.GetCurrentMoonPhaseInfoForDate();
55 m_TimeIcon.SetRotation(moonPhase.GetMoonphaseImageRotation());
56 moonPhase.SetIconTo(m_TimeIcon);
60 m_TimeIcon.SetRotation(0);
61 dayTimeUIInfo.SetIconTo(m_TimeIcon);
67 if (m_TimeAndWeatherManagerEntity.GetIsDayAutoAdvanced())
69 float timeMultiplier = 86400 / m_TimeAndWeatherManagerEntity.GetDayDuration();
70 int TimeMultiplierInt = timeMultiplier;
72 bool visible = !(m_bHideTimeMultiplierIfOne && (TimeMultiplierInt == 1 && (timeMultiplier - TimeMultiplierInt) < 0.1));
73 m_TimeMultiplier.SetVisible(visible);
77 if ((timeMultiplier - TimeMultiplierInt) != 0)
78 m_TimeMultiplier.SetTextFormat(m_sTimeMultiplierFormat, timeMultiplier.ToString(-1, 1));
80 m_TimeMultiplier.SetTextFormat(m_sTimeMultiplierFormat, TimeMultiplierInt);
85 m_TimeMultiplier.SetText(m_sNoTimeProgression);
86 m_TimeMultiplier.SetVisible(
true);
96 override void HandlerAttachedScripted(Widget w)
101 m_TimeText = TextWidget.Cast(w.FindAnyWidget(m_sTimeTextName));
102 m_TimeIcon = ImageWidget.Cast(w.FindAnyWidget(m_sTimeIconName));
103 m_TimeMultiplier = TextWidget.Cast(w.FindAnyWidget(m_sTimeMultiplierName));
105 if (!m_TimeText && !m_TimeIcon && !m_TimeMultiplier)
107 Print(
"'SCR_IngameClockUIComponent' is has no time time widgets and therefore won't function", LogLevel.ERROR);
112 m_TimeAndWeatherManagerEntity = world.GetTimeAndWeatherManager();
113 if (!m_TimeAndWeatherManagerEntity)
115 Print(
"'SCR_IngameClockUIComponent' could not find the TimeAndWeatherManager", LogLevel.ERROR);
120 GetGame().GetCallqueue().CallLater(UpdateIngameClock, m_fUpdateFreq * 1000,
true);
125 override void HandlerDeattached(Widget w)
127 if (m_TimeAndWeatherManagerEntity)
128 GetGame().GetCallqueue().Remove(UpdateIngameClock);