Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TransportUnitUI.c
Go to the documentation of this file.
2{
3 [Attribute("TransportUnitName")]
5
6 [Attribute("VehicleActivityIcon")]
8
9 [Attribute("DestinationName")]
11
12 [Attribute("VehicleConditionIcon")]
14
15 [Attribute("SourceBaseComboBox")]
17
18 [Attribute("ModularButton")]
20
21 [Attribute("{357AD0CC75BA2313}UI/Textures/LogisticTeamState.imageset", UIWidgets.ResourceNamePicker, params: "imageset")]
23
24 [Attribute("Waiting", desc: "Used for every other resupply task solver state.")]
26
27 [Attribute("OnRoadForward")]
28 protected string m_sForwardArrows;
29
30 [Attribute("MissingVehicle")]
32
33 [Attribute("LoadedFull")]
35
36 [Attribute("LoadedEmpty")]
38
39 [Attribute("0.98 0.26 0.26 1", UIWidgets.ColorPicker)]
40 protected ref Color m_FaultStateColor;
41
42 [Attribute(UIColors.GetColorAttribute(GUIColors.ENABLED), UIWidgets.ColorPicker)]
44
45 protected SCR_TaskSolverManagerComponent m_TaskSolverManager;
47
52 protected SCR_ModularButtonComponent m_wModularButton;
53
55 protected ref array<Widget> m_aComboBoxWidgets = {};
56
57 //------------------------------------------------------------------------------------------------
58 void Init(SCR_TransportUnitComponent transportUnit)
59 {
60 m_TransportUnit = transportUnit;
61 if (!m_TransportUnit)
62 return;
63
64 m_TaskSolverManager = SCR_TaskSolverManagerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_TaskSolverManagerComponent));
66 return;
67
68 SetName(m_TransportUnit.GetAIGroup());
70 SetVehicleActivityIcon(m_TransportUnit.GetResupplyTaskSolverState());
71 SetVehicleDestinationName(m_TransportUnit.GetResupplyTaskSolverState());
72
74
75 m_TransportUnit.GetOnVehicleResourcesValueChanged().Insert(OnVehicleResourcesValueChanged);
76 m_TransportUnit.GetOnVehicleChanged().Insert(OnVehicleChanged);
77 m_TransportUnit.GetOnResupplyTaskSolverStateChanged().Insert(OnResupplyTakSolverStateChanged);
78 }
79
80 //------------------------------------------------------------------------------------------------
81 void Deinit()
82 {
84 {
85 m_SourceBaseComboBox.m_OnChanged.Remove(OnSourceBaseChanged);
88 }
89
91 {
92 m_TransportUnit.GetOnVehicleResourcesValueChanged().Remove(OnVehicleResourcesValueChanged);
93 m_TransportUnit.GetOnVehicleChanged().Remove(OnVehicleChanged);
94 m_TransportUnit.GetOnResupplyTaskSolverStateChanged().Remove(OnResupplyTakSolverStateChanged);
95 }
96 }
97
98 //------------------------------------------------------------------------------------------------
100 {
101 if (!m_wModularButton)
102 return;
103
104 GetGame().GetWorkspace().SetFocusedWidget(m_wModularButton.GetRootWidget());
105 }
106
107 //------------------------------------------------------------------------------------------------
108 protected bool SetTexture(ImageWidget widget, ResourceName texture, string image = "", Color color = null)
109 {
110 if (!widget || texture == ResourceName.Empty)
111 return false;
112
113 bool success;
114 if (texture.EndsWith(".edds"))
115 success = widget.LoadImageTexture(0, texture);
116 else
117 success = widget.LoadImageFromSet(0, texture, image);
118
119 if (success && color)
120 widget.SetColor(color);
121
122 return success;
123 }
124
125 //------------------------------------------------------------------------------------------------
126 protected void OnVehicleChanged(Vehicle vehicle, Vehicle previousVehicle)
127 {
129 }
130
131 //------------------------------------------------------------------------------------------------
133 {
134 if (m_TransportUnit.IsVehicleUsable())
135 return false;
136
138 if (!resuplyTaskSolveEntry)
139 return false;
140
141 SCR_ConditionCheckUIEntry conditionCheckUIEntry = resuplyTaskSolveEntry.GetTaskSolverEntry(m_TransportUnit.GetVehicleFailedConditionType());
142 if (!conditionCheckUIEntry)
143 return false;
144
145 SCR_UIInfo failedConditionUIInfo = conditionCheckUIEntry.GetFailedConditionUIInfo();
146 if (!failedConditionUIInfo)
147 return false;
148
149 if (failedConditionUIInfo.SetIconTo(m_wVehicleConditionIcon))
151
152 return true;
153 }
154
155 //------------------------------------------------------------------------------------------------
156 protected void OnVehicleResourcesValueChanged(float aggregatedResourcesValue)
157 {
158 if (aggregatedResourcesValue < 0)
159 return;
160
161 if (m_TransportUnit.GetSolver().GetResupplyTaskSolverState() != SCR_EResupplyTaskSolverState.LOADING_SUPPLIES && aggregatedResourcesValue > 0)
162 {
164 }
165 else
166 {
168 }
169 }
170
171 //------------------------------------------------------------------------------------------------
172 protected void UpdateVehicleConditionIcon(Vehicle vehicle)
173 {
174 if (m_TransportUnit.HasVehicle())
175 {
176 bool vehicleConditionIconUpdated = UpdateVehicleConditionIconBasedOnDamage();
177 if (vehicleConditionIconUpdated)
178 return;
179
180 OnVehicleResourcesValueChanged(m_TransportUnit.GetVehicleAggregatedResourceValue())
181 }
182 else
183 {
185 }
186 }
187
188 //------------------------------------------------------------------------------------------------
189 protected void OnResupplyTakSolverStateChanged(SCR_EResupplyTaskSolverState resupplyTaskSolverState)
190 {
191 SetVehicleActivityIcon(resupplyTaskSolverState);
192 SetVehicleDestinationName(resupplyTaskSolverState);
193 }
194
195 //------------------------------------------------------------------------------------------------
196 protected void SetVehicleActivityIcon(SCR_EResupplyTaskSolverState resupplyTaskSolverState)
197 {
198 if (resupplyTaskSolverState == SCR_EResupplyTaskSolverState.MOVING_TO_SUPPLIED_BASE || resupplyTaskSolverState == SCR_EResupplyTaskSolverState.MOVING_TO_SOURCE_BASE)
199 {
201 }
202 else
203 {
205 }
206 }
207
208 //------------------------------------------------------------------------------------------------
209 protected void SetVehicleDestinationName(SCR_EResupplyTaskSolverState resupplyTaskSolverState)
210 {
212 return;
213
214 m_wDestinationName.SetText(m_TransportUnit.GetDestinationName());
215 }
216
217 //------------------------------------------------------------------------------------------------
218 protected void SetupComboBox()
219 {
220 SCR_CampaignMilitaryBaseManager baseManager = SCR_GameModeCampaign.GetInstance().GetBaseManager();
221 array<SCR_CampaignMilitaryBaseComponent> bases = {};
222 baseManager.GetBases(bases, m_TransportUnit.GetFaction());
223
224 int selectedIndex = -1;
225 m_SourceBaseComboBox.ClearAll();
226 m_SourceBaseComboBox.AddItem("-");
227 foreach (int index, SCR_MilitaryBaseComponent base : bases)
228 {
229 if (base == m_TransportUnit.GetSourceBase())
230 {
231 selectedIndex = index;
232 }
233
234 m_SourceBaseComboBox.AddItem(base.GetCallsignDisplayName(), false, base);
235 }
236
237 m_SourceBaseComboBox.SetCurrentItem(selectedIndex + 1);
238 m_SourceBaseComboBox.m_OnChanged.Insert(OnSourceBaseChanged);
241 }
242
243 //------------------------------------------------------------------------------------------------
244 protected void SetName(SCR_AIGroup transportGroup)
245 {
246 if (!m_wTransportUnitName || !transportGroup)
247 return;
248
249 string company, platoon, squad, character, format;
250 transportGroup.GetCallsigns(company, platoon, squad, character, format);
251 m_wTransportUnitName.SetTextFormat(format, company, platoon, squad, character);
252 }
253
254 //------------------------------------------------------------------------------------------------
255 protected void OnSourceBaseChanged(SCR_ComboBoxComponent comboBoxComponent, int index)
256 {
257 PlayerController playerController = GetGame().GetPlayerController();
258 if (!playerController)
259 return;
260
261 SCR_PlayerControllerGroupComponent playerControllerGroup = SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
262 if (!playerControllerGroup)
263 return;
264
265 if (m_TransportUnit)
266 {
268 playerControllerGroup.SetTransportUnitSourceBase(m_TransportUnit, militaryBase);
269 }
270
271 if (m_aComboBoxWidgets.IsIndexValid(index))
272 {
274 if (widget)
275 {
276 WidgetFlags flags = widget.GetFlags();
277 widget.SetFlags(SCR_Enum.SetFlag(flags, WidgetFlags.NOFOCUS));
278 }
279 }
280 }
281
282 //------------------------------------------------------------------------------------------------
283 protected void OnComboBoxListOpened()
284 {
286 if (!mapEntity)
287 return;
288
289 // Handle Context so the player does not zoom in/out the map while scrolling through list
290 SCR_MapCursorModule cursorModule = SCR_MapCursorModule.Cast(mapEntity.GetMapModule(SCR_MapCursorModule));
291 if (cursorModule)
292 cursorModule.HandleContextualMenu(false);
293
294 m_aComboBoxWidgets.Clear();
295 m_SourceBaseComboBox.GetElementWidgets(m_aComboBoxWidgets);
296 }
297
298 //------------------------------------------------------------------------------------------------
299 protected void OnComboBoxListClosed()
300 {
302 if (!mapEntity)
303 return;
304
305 // List is closed, return context so the player can navigate through the map
306 SCR_MapCursorModule cursorModule = SCR_MapCursorModule.Cast(mapEntity.GetMapModule(SCR_MapCursorModule));
307 if (cursorModule)
308 cursorModule.HandleContextualMenu(true);
309
310 FocusButton();
311 }
312
313 //------------------------------------------------------------------------------------------------
314 void OnModularButtonClicked(SCR_ModularButtonComponent button)
315 {
316 m_SourceBaseComboBox.OpenList();
317 }
318
319 //------------------------------------------------------------------------------------------------
320 override void HandlerAttached(Widget w)
321 {
323 return;
324
325 super.HandlerAttached(w);
326
331
333
334 Widget button = w.FindAnyWidget(m_sModularButtonWidgetName);
335 if (!button)
336 return;
337
338 m_wModularButton = SCR_ModularButtonComponent.Cast(button.FindHandler(SCR_ModularButtonComponent));
339 if (!m_wModularButton)
340 return;
341
342 m_wModularButton.m_OnClicked.Insert(OnModularButtonClicked);
343 }
344
345 //------------------------------------------------------------------------------------------------
346 override void HandlerDeattached(Widget w)
347 {
349 return;
350
351 super.HandlerAttached(w);
352
354 m_wModularButton.m_OnClicked.Remove(OnModularButtonClicked);
355 }
356}
SCR_EAIThreatSectorFlags flags
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Color.c:13
void GetCallsigns(out string company, out string platoon, out string squad, out string character, out string format)
int GetBases(notnull out array< SCR_CampaignMilitaryBaseComponent > bases, Faction faction=null)
SCR_UIInfo GetFailedConditionUIInfo()
static bool IsEditMode()
Definition Functions.c:1566
SCR_MapModuleBase GetMapModule(typename moduleType)
static SCR_MapEntity GetMapInstance()
Get map entity instance.
SCR_ConditionCheckUIEntry GetTaskSolverEntry(int conditionCheckType)
ImageWidget m_wVehicleConditionIcon
SCR_ModularButtonComponent m_wModularButton
override void HandlerDeattached(Widget w)
string m_sFullyLoadedVehicleConditionImageName
void OnSourceBaseChanged(SCR_ComboBoxComponent comboBoxComponent, int index)
void OnModularButtonClicked(SCR_ModularButtonComponent button)
void SetVehicleActivityIcon(SCR_EResupplyTaskSolverState resupplyTaskSolverState)
SCR_ComboBoxComponent m_SourceBaseComboBox
ResourceName m_sTransportUnitImageStateResourceName
override void HandlerAttached(Widget w)
void Init(SCR_TransportUnitComponent transportUnit)
bool SetTexture(ImageWidget widget, ResourceName texture, string image="", Color color=null)
string m_sNotLoadedVehicleConditionImageName
bool UpdateVehicleConditionIconBasedOnDamage()
ImageWidget m_wVehicleActivityIcon
void OnVehicleResourcesValueChanged(float aggregatedResourcesValue)
void OnResupplyTakSolverStateChanged(SCR_EResupplyTaskSolverState resupplyTaskSolverState)
SCR_TaskSolverManagerComponent m_TaskSolverManager
void SetName(SCR_AIGroup transportGroup)
void OnVehicleChanged(Vehicle vehicle, Vehicle previousVehicle)
void SetVehicleDestinationName(SCR_EResupplyTaskSolverState resupplyTaskSolverState)
ref array< Widget > m_aComboBoxWidgets
SCR_TransportUnitComponent m_TransportUnit
void UpdateVehicleConditionIcon(Vehicle vehicle)
bool SetIconTo(ImageWidget imageWidget)
Definition SCR_UIInfo.c:102
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14