Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapLightUI.c
Go to the documentation of this file.
2{
3 NONE,
7}
8
9[BaseContainerProps(configRoot: true)]
10class SCR_MapLightConfig
11{
12 [Attribute("", UIWidgets.Object, "2D map light modes")]
13 ref array<ref SCR_MapLightMode> m_aMapLightModes;
14}
15
18{
19 [Attribute("0", UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EMapLightMode), desc: "Select light mode to configure")]
20 EMapLightMode m_eMode;
21
22 [Attribute("1 1 1 1", UIWidgets.ColorPicker, desc: "Light overlay color")]
23 ref Color m_vColor;
24
25 [Attribute("1", UIWidgets.Slider, desc: "Light overlay opacity", "0 1 0.05")]
26 float m_fOverlayOpacity;
27
28 [Attribute("1", UIWidgets.Slider, desc: "Light cone opacity", "0 1 0.05")]
29 float m_fLightConeOpacity;
30
31 [Attribute("{FFCDEB9793720A1C}UI/Textures/Sights/binocular_vignette2_ca.edds", UIWidgets.ResourceNamePicker, desc: "Zones config", params: "edds")]
32 ResourceName m_sConeTexture;
33}
34
36class SCR_MapLightUI : SCR_MapUIBaseComponent
37{
38 protected bool m_bActive = false;
39 protected bool m_bIsDark = false;
40 protected float m_fSunriseTime;
41 protected float m_fSunsetTime;
43
46 protected Widget m_wFillTop;
48 protected Widget m_wConeImg;
49
51 protected SCR_MapCursorModule m_CursorModule;
52
53 // TEMP
54 protected ref SCR_MapLightConfig m_LightCfg;
55
56 //------------------------------------------------------------------------------------------------
59 {
60 if (!m_bActive)
62 else
64 }
65
66 //------------------------------------------------------------------------------------------------
68 protected void ActivateLight()
69 {
70 UpdateTime();
71
72 // Not dark enough
73 if (!m_bIsDark)
74 return;
75
77 if (!gadgetManager)
78 return;
79
80 IEntity flashlight = gadgetManager.GetGadgetByType(EGadgetType.FLASHLIGHT);
81 if (flashlight)
82 {
83 m_bActive = true;
84 m_wLightCone.SetVisible(true);
85 m_eLightMode = EMapLightMode.FLASH_DEFAULT;
86 // SetMode based on flashlight lense
87 }
88 //else
89 //m_eLightMode = EMapLightMode.LIGHTER;
90
92 }
93
94 //------------------------------------------------------------------------------------------------
96 protected void DeactivateLight()
97 {
98 m_bActive = false;
99 m_wLightCone.SetVisible(false);
102 }
103
104 //------------------------------------------------------------------------------------------------
106 protected void UpdateLightMode()
107 {
108 if (m_LightCfg)
109 {
110 foreach ( SCR_MapLightMode mode : m_LightCfg.m_aMapLightModes )
111 {
112 if (mode.m_eMode == m_eLightMode)
113 {
114 m_wLightOverlay.SetColor(mode.m_vColor);
115 m_wLightOverlay.SetOpacity(mode.m_fOverlayOpacity);
116
117 // Update light cone texture
118 if (m_eLightMode != EMapLightMode.NONE)
119 {
120 ImageWidget.Cast(m_wConeImg).LoadImageTexture(0, mode.m_sConeTexture);
121 m_wLightCone.SetOpacity(mode.m_fLightConeOpacity);
122 }
123
124 break;
125 }
126 }
127 }
128 }
129
130 //------------------------------------------------------------------------------------------------
132 protected void UpdateTime()
133 {
135 return;
136
137 if (!m_TimeMgr)
138 return;
139
140 float time = m_TimeMgr.GetTimeOfTheDay();
141
142 // day/night
143 m_bIsDark = time < m_fSunriseTime || time > m_fSunsetTime;
144 m_wLightOverlay.SetVisible(m_bIsDark);
145 }
146
147 //------------------------------------------------------------------------------------------------
149 protected void UpdatePosition()
150 {
151 float sizeX, sizeY, cursorX, cursorY;
152
153 SCR_MapCursorInfo cursorInfo = m_CursorModule.GetCursorInfo();
154 cursorX = cursorInfo.x;
155 cursorY = cursorInfo.y;
156
157 m_wConeImg.GetScreenSize(sizeX, sizeY);
158
159 // calculate and set new size of top & left fill imageWidgets
160 WorkspaceWidget workspace = GetGame().GetWorkspace();
161 cursorX = cursorX - workspace.DPIUnscale(sizeX)/2;
162 cursorY = cursorY - workspace.DPIUnscale(sizeY)/2;
163
164 ImageWidget.Cast(m_wFillLeft).SetSize(cursorX, 0);
165 ImageWidget.Cast(m_wFillTop).SetSize(0, cursorY);
166 }
167
168 //------------------------------------------------------------------------------------------------
171 protected void Init(Widget widget)
172 {
173 m_wLightOverlay = widget.FindAnyWidget("LightOverlay");
174 m_wLightCone = widget.FindAnyWidget("LightCone");
175 m_wFillTop = widget.FindAnyWidget("FillTop");
176 m_wFillLeft = widget.FindAnyWidget("FillLeft");
177 m_wConeImg = widget.FindAnyWidget("Cone");
178
179 if (m_wLightCone)
180 m_wLightCone.SetVisible(false);
181
182 if (m_wLightOverlay)
183 m_wLightOverlay.SetVisible(false);
184
185 ChimeraWorld world = GetGame().GetWorld();
186 m_TimeMgr = world.GetTimeAndWeatherManager();
187 if (m_TimeMgr)
188 {
189 m_TimeMgr.GetSunriseHour(m_fSunriseTime);
190 m_TimeMgr.GetSunsetHour(m_fSunsetTime);
191 }
192
193 // TODO hardcoded
194 if (!m_LightCfg)
195 {
196 Resource container = BaseContainerTools.LoadContainer("{D442DD4867C97496}Configs/Map/MapLightModes.conf");
197 if (container)
198 m_LightCfg = SCR_MapLightConfig.Cast( BaseContainerTools.CreateInstanceFromContainer( container.GetResource().ToBaseContainer() ) );
199 }
200 }
201
202 //------------------------------------------------------------------------------------------------
203 // OVERRIDES
204 //------------------------------------------------------------------------------------------------
205
206 //------------------------------------------------------------------------------------------------
207 override void OnMapOpen(MapConfiguration config)
208 {
209 super.OnMapOpen(config);
210
212 m_CursorModule = SCR_MapCursorModule.Cast(SCR_MapEntity.GetMapInstance().GetMapModule(SCR_MapCursorModule));
213
215
217 }
218
219 //------------------------------------------------------------------------------------------------
220 override void OnMapClose(MapConfiguration config)
221 {
223
224 m_wLightOverlay.SetVisible(false);
225 m_bIsDark = false;
226
227 super.OnMapClose(config);
228 }
229
230 //------------------------------------------------------------------------------------------------
231 override void Update(float timeSlice)
232 {
233 if (!m_TimeMgr)
234 return;
235
236 UpdateTime();
237
240 }
241}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_MapCursorModule m_CursorModule
ref SCR_MapLightConfig m_LightCfg
FLASH_DEFAULT
FLASH_RED
void DeactivateLight()
Deactivate map light.
void UpdatePosition()
Update light position.
Widget m_wFillTop
LIGHTER
EMapLightMode m_eLightMode
void ActivateLight()
Activate map light.
bool m_bIsDark
class SCR_MapLightMode m_bActive
Map light effects.
void ToggleActive()
Toggle map light.
Widget m_wFillLeft
Widget m_wConeImg
float m_fSunsetTime
EMapLightMode
void UpdateLightMode()
Use config to configure light when switching modes.
Widget m_wLightOverlay
Widget m_wLightCone
float m_fSunriseTime
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
TimeAndWeatherManagerEntity m_TimeMgr
void UpdateTime()
Definition Color.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
IEntity GetGadgetByType(EGadgetType type)
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
SCR_MapModuleBase GetMapModule(typename moduleType)
MapConfiguration GetMapConfig()
Get map config.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
void OnMapOpen(MapConfiguration config)
void OnMapClose(MapConfiguration config)
void Init()
Init method for cases where all modules and components should be loaded already so constructor cannot...
static IEntity GetLocalControlledEntity()
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
SCR_FieldOfViewSettings Attribute