Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_IngameDateUIComponent.c
Go to the documentation of this file.
1 class SCR_IngameDateUIComponent : ScriptedWidgetComponent
2 {
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;
5 
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;
8 
9  [Attribute("1", desc: "If true month will be written in full text, else month will be a number")]
10  protected bool m_bMonthAsText;
11 
12  [Attribute("2", desc: "Time until the UI will update in seconds")]
13  protected float m_fUpdateFreq;
14 
15  protected int m_iDayLastCheckedYear = -1;
16  protected int m_iDayLastCheckedMonth = -1;
17  protected int m_iDayLastCheckedDay = -1;
18 
19  //~ References
20  protected TextWidget m_DateText;
21  protected TextWidget m_DayText;
22  protected TimeAndWeatherManagerEntity m_TimeAndWeatherManagerEntity;
23 
24 
25  protected void UpdateIngameDate()
26  {
27  int day, month, year;
28  m_TimeAndWeatherManagerEntity.GetDate(year, month, day);
29 
30  //~ Set date
31  if (m_DateText)
32  {
33  string date = SCR_DateTimeHelper.GetDateString(day, month, year, m_bMonthAsText);
34  m_DateText.SetText(date);
35  }
36 
37  if (m_DayText)
38  {
39  if (m_iDayLastCheckedDay != day || m_iDayLastCheckedMonth != month || m_iDayLastCheckedYear != year)
40  {
41  m_iDayLastCheckedDay = day;
42  m_iDayLastCheckedMonth = month;
43  m_iDayLastCheckedYear = year;
44 
45  m_DayText.SetText(m_TimeAndWeatherManagerEntity.GetWeekDayString());
46  }
47  }
48 
49  }
50 
51  override void HandlerAttached(Widget w)
52  {
53  if (SCR_Global.IsEditMode())
54  return;
55 
56  m_DateText = TextWidget.Cast(w.FindAnyWidget(m_sDateTextName));
57  m_DayText = TextWidget.Cast(w.FindAnyWidget(m_sDayTextName));
58 
59  if (!m_DateText && !m_DayText)
60  {
61  Print("'SCR_IngameDateUIComponent' is missing both date and day widget and therefore won't function", LogLevel.ERROR);
62  return;
63  }
64 
65  ChimeraWorld world = GetGame().GetWorld();
66  m_TimeAndWeatherManagerEntity = world.GetTimeAndWeatherManager();
67  if (!m_TimeAndWeatherManagerEntity)
68  {
69  Print("'SCR_IngameDateUIComponent' could not find the TimeAndWeatherManager", LogLevel.ERROR);
70  return;
71  }
72 
73  UpdateIngameDate();
74  GetGame().GetCallqueue().CallLater(UpdateIngameDate, m_fUpdateFreq * 1000, true);
75 
76  }
77  override void HandlerDeattached(Widget w)
78  {
79  if (m_TimeAndWeatherManagerEntity)
80  GetGame().GetCallqueue().Remove(UpdateIngameDate);
81  }
82 };
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_IngameDateUIComponent
Definition: SCR_IngameDateUIComponent.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_DateTimeHelper
Definition: SCR_DateTimeHelper.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_Global
Definition: Functions.c:6