Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_IngameClockUIComponent.c
Go to the documentation of this file.
1
3{
4 [Attribute("Time", desc: "Clock needs at least the Time icon, time multiplier, time pause Icon or Time Text to function")]
5 protected string m_sTimeTextName;
6
7 [Attribute("DayTime_Icon", desc: "Clock needs at least the Time icon, time multiplier, time pause Icon or Time Text to function")]
8 protected string m_sTimeIconName;
9
10 [Attribute("Time_Multiplier", desc: "Clock needs at least the Time icon, time multiplier, time pause Icon or Time Text to function")]
11 protected string m_sTimeMultiplierName;
12
13 [Attribute("Time_Paused_Icon", desc: "Clock needs at least the Time icon, time multiplier, time pause Icon or Time Text to function")]
14 protected string m_sTimeStoppedIconName;
15
16 [Attribute("#AR-ValueUnit_Short_Multiplier", uiwidget: UIWidgets.LocaleEditBox)]
17 protected string m_sTimeMultiplierFormat;
18
19 [Attribute("#AR-Weather_Forecast_NoTimeProgression", uiwidget: UIWidgets.LocaleEditBox)]
20 protected string m_sNoTimeProgressionHint;
21
22 [Attribute("#AR-Editor_Clock_IngameTime_Name", uiwidget: UIWidgets.LocaleEditBox)]
23 protected string m_sInGameTimeHint;
24
25 [Attribute("1", desc: "Time until the UI will update in seconds")]
26 protected float m_fUpdateFreq;
27
28 [Attribute("1", desc: "If true will hide the time multiplier if one (and assigned)")]
30
31 [Attribute(desc: "If the current time of day is in this Phase show moonphase instead of daytimeIcon", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EDayTimeEnums))]
32 protected ref array<EDayTimeEnums> m_aShowMoonphaseAtDayTimes;
33
34 //~ References
38 protected ImageWidget m_TimeStoppedIcon; //~ Icon when simulation is paused
41
42 //======================== CLOCK UPDATE ========================\\
43
44 //------------------------------------------------------------------------------------------------
45 protected void UpdateIngameClock()
46 {
47 //Get time
48 if (m_TimeText)
49 {
50 int hour, minute, sec;
51 m_TimeAndWeatherManagerEntity.GetHoursMinutesSeconds(hour, minute, sec);
53 }
54
55 if (m_TimeIcon)
56 {
57 SCR_UIInfo dayTimeUIInfo;
58 EDayTimeEnums dayTimePhase = m_TimeAndWeatherManagerEntity.GetCurrentDayTimeUIInfoAndPhase(dayTimeUIInfo);
59
60 if (m_aShowMoonphaseAtDayTimes.Contains(dayTimePhase))
61 {
62 SCR_MoonPhaseUIInfo moonPhase = m_TimeAndWeatherManagerEntity.GetCurrentMoonPhaseInfoForDate();
63 m_TimeIcon.SetRotation(moonPhase.GetMoonphaseImageRotation());
64 moonPhase.SetIconTo(m_TimeIcon);
65 }
66 else
67 {
68 m_TimeIcon.SetRotation(0);
69 dayTimeUIInfo.SetIconTo(m_TimeIcon);
70 }
71 }
72
74 {
75 if (m_TimeAndWeatherManagerEntity.GetIsDayAutoAdvanced())
76 {
77 float timeMultiplier = 86400 / m_TimeAndWeatherManagerEntity.GetDayDuration();
78 int TimeMultiplierInt = timeMultiplier;
79
80 bool visible = !(m_bHideTimeMultiplierIfOne && (TimeMultiplierInt == 1 && (timeMultiplier - TimeMultiplierInt) < 0.1));
81 m_TimeMultiplier.SetVisible(visible);
82 m_TimeStoppedIcon.SetVisible(false);
83 m_CustomTooltipUIComponent.GetInfo().SetDescription(m_sInGameTimeHint);
84
85 if (visible)
86 {
87 if ((timeMultiplier - TimeMultiplierInt) != 0)
88 m_TimeMultiplier.SetTextFormat(m_sTimeMultiplierFormat, timeMultiplier.ToString(-1, 1));
89 else
90 m_TimeMultiplier.SetTextFormat(m_sTimeMultiplierFormat, TimeMultiplierInt);
91 }
92 }
93 else
94 {
95 // When Time progression is paused/No Time Progression Show Pause Icon hide multiplier text
97 m_TimeStoppedIcon.SetVisible(true);
98 m_TimeMultiplier.SetVisible(false);
99 }
100 }
101
102 }
103
104 //======================== ATTACH/DEATTACH HANDLER ========================\\
105
106 //------------------------------------------------------------------------------------------------
107 //On Init
109 {
111 return;
112
113 m_TimeText = TextWidget.Cast(w.FindAnyWidget(m_sTimeTextName));
114 m_TimeIcon = ImageWidget.Cast(w.FindAnyWidget(m_sTimeIconName));
115 m_TimeMultiplier = TextWidget.Cast(w.FindAnyWidget(m_sTimeMultiplierName));
117
119 {
120 Print("'SCR_IngameClockUIComponent' is has no time time widgets and therefore won't function", LogLevel.ERROR);
121 return;
122 }
123
126 {
127 Print("'SCR_IngameClockUIComponent' is missing custom editor tooltip component", LogLevel.ERROR);
128 return;
129 }
130
131 ChimeraWorld world = GetGame().GetWorld();
132 m_TimeAndWeatherManagerEntity = world.GetTimeAndWeatherManager();
134 {
135 Print("'SCR_IngameClockUIComponent' could not find the TimeAndWeatherManager", LogLevel.ERROR);
136 return;
137 }
138
140 GetGame().GetCallqueue().CallLater(UpdateIngameClock, m_fUpdateFreq * 1000, true);
141 }
142
143 //------------------------------------------------------------------------------------------------
144 //On Destroy
145 override void HandlerDeattached(Widget w)
146 {
148 GetGame().GetCallqueue().Remove(UpdateIngameClock);
149
150 }
151}
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static string GetTimeFormattingHoursMinutes(int hours, int minutes, ETimeFormatParam hideEmpty=0, ETimeFormatParam hideLeadingZeroes=0)
static bool IsEditMode()
Definition Functions.c:1566
Gets the Ingame time and displays it on a UI text element.
ref array< EDayTimeEnums > m_aShowMoonphaseAtDayTimes
SCR_CustomTooltipTargetEditorUIComponent m_CustomTooltipUIComponent
override void HandlerAttachedScripted(Widget w)
TimeAndWeatherManagerEntity m_TimeAndWeatherManagerEntity
override void HandlerDeattached(Widget w)
bool SetIconTo(ImageWidget imageWidget)
Definition SCR_UIInfo.c:102
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute