Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DateAttributeDynamicDescription.c
Go to the documentation of this file.
1
4[BaseContainerProps(), BaseContainerCustomStringTitleField("Date description (CUSTOM)")]
6{
7 [Attribute("#AR-Editor_Attribute_Date_Description_NoSunSetOrRise", desc: "Text shown in description when there is no sunset nor sunrise")]
8 protected string m_sNoSunriseSunSet;
9
11 protected SCR_AttributesManagerEditorComponent m_AttributeManager;
12
13 //------------------------------------------------------------------------------------------------
14 override void InitDynamicDescription(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
15 {
16 super.InitDynamicDescription(attribute);
17
19 {
20 ChimeraWorld world = GetGame().GetWorld();
21 m_TimeAndWeatherManager = world.GetTimeAndWeatherManager();
22 }
23
25 m_AttributeManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
26
27 if (!attribute.IsInherited(SCR_DateEditorAttribute))
28 Print("'SCR_DateAttributeDynamicDescription' is not attached to the 'SCR_DateEditorAttribute'!", LogLevel.ERROR);
29 }
30
31 //------------------------------------------------------------------------------------------------
32 override bool IsValid(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
33 {
34 if (!super.IsValid(attribute, attributeUi) || !attribute.IsInherited(SCR_DateEditorAttribute))
35 return false;
36
37 return m_TimeAndWeatherManager != null;
38 }
39
40 //------------------------------------------------------------------------------------------------
41 override void GetDescriptionData(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi, out SCR_EditorAttributeUIInfo uiInfo, out string param1 = string.Empty, out string param2 = string.Empty, out string param3 = string.Empty)
42 {
43 SCR_BaseEditorAttributeVar var = attribute.GetVariableOrCopy();
44 if (!var)
45 return;
46
47 SCR_DateEditorAttribute dateAttribute = SCR_DateEditorAttribute.Cast(attribute);
48 if (!dateAttribute)
49 return;
50
51 float daytime = 0;
52
53 //~ If has daytime var
55 if (m_AttributeManager && m_AttributeManager.GetAttributeVariable(SCR_DaytimeEditorAttribute, dayTimeVar))
56 daytime = dayTimeVar.GetFloat() / 3600;
57
58 array<int> yearArray = {};
59 dateAttribute.GetYearArray(yearArray);
60
61 vector date = var.GetVector();
62
63 int day = date[0] +1;
64 int month = date[1] +1;
65 int year = yearArray[date[2]];
66
67 float timeZoneOffset = m_TimeAndWeatherManager.GetTimeZoneOffset();
68 float dstOffset = m_TimeAndWeatherManager.GetDSTOffset();
69 float latitude = m_TimeAndWeatherManager.GetCurrentLatitude();
70
71 SCR_MoonPhaseUIInfo moonPhaseInfo = m_TimeAndWeatherManager.GetMoonPhaseInfoForDate(year, month, day, daytime, timeZoneOffset, dstOffset, latitude);
72
73 float sunRiseTime, sunSetTime;
74 bool hasSunRise = m_TimeAndWeatherManager.GetSunriseHourForDate(year, month, day, m_TimeAndWeatherManager.GetCurrentLatitude(), m_TimeAndWeatherManager.GetCurrentLongitude(), m_TimeAndWeatherManager.GetTimeZoneOffset(), m_TimeAndWeatherManager.GetDSTOffset(), sunRiseTime);
75 bool hasSunSet = m_TimeAndWeatherManager.GetSunsetHourForDate(year, month, day, m_TimeAndWeatherManager.GetCurrentLatitude(), m_TimeAndWeatherManager.GetCurrentLongitude(), m_TimeAndWeatherManager.GetTimeZoneOffset(), m_TimeAndWeatherManager.GetDSTOffset(), sunSetTime);
76
77 string sunRiseName, sunSetName;
78
79 if (!hasSunRise)
80 sunRiseName = m_sNoSunriseSunSet;
81 else
82 sunRiseName = SCR_FormatHelper.GetTimeFormattingHideSeconds(sunRiseTime * 3600, ETimeFormatParam.DAYS);
83 if (!hasSunRise)
84 sunSetName = m_sNoSunriseSunSet;
85 else
86 sunSetName = SCR_FormatHelper.GetTimeFormattingHideSeconds(sunSetTime * 3600, ETimeFormatParam.DAYS);
87
89 param1 = sunRiseName;
90 param2 = sunSetName;
91 param3 = moonPhaseInfo.GetName();
92 }
93};
ETimeFormatParam
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_HitZoneGroupNameHolder BaseContainerCustomStringTitleField("USE INHERITED VERSION ONLY!")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
override bool IsValid(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
SCR_AttributesManagerEditorComponent m_AttributeManager
override void InitDynamicDescription(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
override void GetDescriptionData(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi, out SCR_EditorAttributeUIInfo uiInfo, out string param1=string.Empty, out string param2=string.Empty, out string param3=string.Empty)
void GetYearArray(notnull out array< int > yearArray)
UIInfo used by editor attribute system.
static string GetTimeFormattingHideSeconds(int totalSeconds, ETimeFormatParam hideEmpty=0, ETimeFormatParam hideLeadingZeroes=0)
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
T3 param3
Definition tuple.c:93
T2 param2
Definition tuple.c:92
Tuple param1