Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DateEditorAttribute.c
Go to the documentation of this file.
3{
4 //TODO: Needs proper system to know the order of dmy
5 [Attribute(defvalue: "dmy", desc: "The order in which days, months and years appear. this could be dmy ymd mdy etc. This is a temporary system until a more permanent solution is added")]
6 protected string m_sDateFormatOrder;
7
8 [Attribute(uiwidget: UIWidgets.LocaleEditBox, defvalue: "#AR-Date_Day")]
10
11 [Attribute(uiwidget: UIWidgets.LocaleEditBox, defvalue: "#AR-Date_Month")]
13
14 [Attribute(uiwidget: UIWidgets.LocaleEditBox, defvalue: "#AR-Date_Year")]
16
17 [Attribute(uiwidget: UIWidgets.LocaleEditBox)]
18 protected ref array<ref LocalizedString> m_aMonthList;
19
20 [Attribute(defvalue: "1940")]
21 protected int m_iYearStartDate;
22
23 [Attribute(defvalue: "1995")]
24 protected int m_iYearEndDate;
25
26 protected ref array<int> m_aYearArray = {};
27
28 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
29 {
30 //If opened in global attributes
31 if (!IsGameMode(item))
32 return null;
33
34 GenericEntity ent = GenericEntity.Cast(item);
35 ChimeraWorld world = ent.GetWorld();
36 TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
37 if (!timeManager)
38 return null;
39
40 //Get date
41 vector date = Vector(timeManager.GetDay() -1, timeManager.GetMonth() -1, GetYearIndex(timeManager.GetYear()));
43 }
44
45 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
46 {
47 if (!var) return;
48
49 GenericEntity ent = GenericEntity.Cast(item);
50 ChimeraWorld world = ent.GetWorld();
51 TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
52 if (!timeManager) return;
53
55 vector date = var.GetVector();
56 int day = date[0] +1;
57 int month = date[1] +1;
58 int year = m_aYearArray[date[2]];
59
60 if (item)
61 {
62 SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(ENotification.EDITOR_ATTRIBUTES_DATE_CHANGED, playerID, day, month, year);
63 }
64
65 timeManager.SetDate(year, month, day);
66 }
67
68 override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
69 {
70 if (!var || isInit)
71 return;
72
73 //If date changed set time preset selected false
74 manager.SetAttributeSelected(SCR_TimePresetsEditorAttribute, false, -1);
75 }
76
81 void GetYearArray(notnull out array<int> yearArray)
82 {
84
85 foreach(int year : m_aYearArray)
86 {
87 yearArray.Insert(year);
88 }
89 }
90
91 protected void CreateYearArray()
92 {
93 if (m_aYearArray.Count() != 0)
94 return;
95
96 ChimeraWorld world = GetGame().GetWorld();
97 TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
98 if (!timeManager)
99 return;
100
101 int currentYear = timeManager.GetYear();
102
103 //Safty
104 if (currentYear < m_iYearStartDate)
105 m_iYearStartDate = currentYear;
106 if (currentYear > m_iYearEndDate)
107 m_iYearEndDate = currentYear;
110
111 //Create year list
112 for (int y = m_iYearStartDate; y <= m_iYearEndDate; y++)
113 {
114 m_aYearArray.Insert(y);
115 }
116 }
117
118 protected int GetYearIndex(int year)
119 {
121
122 if (m_aYearArray.Contains(year))
123 {
124 return m_aYearArray.Find(year);
125 }
126 else
127 {
128 return 0;
129 }
130 }
131
132 /* Returns year by given index, called by SCR_DaytimeEditorAttribute preview
133 \param index given index
134 \return int year
135 */
137 {
139
141 return 1990;
142
143 return m_aYearArray[index];
144 }
145
146 override int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
147 {
148 outEntries.Insert(new SCR_BaseEditorAttributeEntryText(GetUIInfo().GetName()));
150 outEntries.Insert(new SCR_BaseEditorAttributeEntryText(m_sDayLabel));
151 outEntries.Insert(new SCR_BaseEditorAttributeEntryText(m_sMonthLabel));
152 outEntries.Insert(new SCR_BaseEditorAttributeEntryText(m_sYearLabel));
154
156 outEntries.Insert(new SCR_EditorAttributeEntryIntArray(m_aYearArray));
157 return outEntries.Count();
158 }
159
160 override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
161 {
162 if (!manager)
163 return;
164
165 SCR_BaseEditorAttribute timeAttribute = manager.GetAttributeRef(SCR_DaytimeEditorAttribute);
166 if (timeAttribute)
167 timeAttribute.PreviewVariable(setPreview, manager);
168 }
169};
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_EditorAttributeEntryStringArray(array< ref LocalizedString > values)
void SCR_BaseEditorAttributeEntryText(string text)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external BaseWorld GetWorld()
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
SCR_EditorAttributeUIInfo GetUIInfo()
static SCR_BaseEditorAttributeVar CreateVector(vector value)
override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
void GetYearArray(notnull out array< int > yearArray)
ref array< ref LocalizedString > m_aMonthList
override int GetEntries(notnull array< ref SCR_BaseEditorAttributeEntry > outEntries)
override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit=false)
override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
override void PreviewVariable(bool setPreview, SCR_AttributesManagerEditorComponent manager)
SCR_FieldOfViewSettings Attribute
proto native vector Vector(float x, float y, float z)