Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TaskListUIComponent.c
Go to the documentation of this file.
9
11class SCR_TaskTabStates
12{
13 [Attribute("", UIWidgets.ComboBox, enumType: SCR_ETaskTabType)]
14 protected SCR_ETaskTabType m_eTabType;
15
16 [Attribute("0", UIWidgets.Flags, "", enumType: SCR_ETaskState)]
17 protected SCR_ETaskState m_eStates;
18
19 //------------------------------------------------------------------------------------------------
20 SCR_ETaskTabType GetTabType()
21 {
22 return m_eTabType;
23 }
24
25 //------------------------------------------------------------------------------------------------
26 SCR_ETaskState GetTaskStates()
27 {
28 return m_eStates;
29 }
30
31 //------------------------------------------------------------------------------------------------
32 bool IsTaskVisible(notnull SCR_Task task)
33 {
34 return true;
35 }
36}
37
39class SCR_AssignableTaskTabStates : SCR_TaskTabStates
40{
41 //------------------------------------------------------------------------------------------------
42 override bool IsTaskVisible(notnull SCR_Task task)
43 {
44 if (SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander())
45 return true;
46
47 SCR_PlayerControllerGroupComponent playerControllerGroupComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
48 if (!playerControllerGroupComponent)
49 return false;
50
51 SCR_TaskExecutor groupExecutor = SCR_TaskExecutor.FromGroup(playerControllerGroupComponent.GetGroupID());
52 if (!groupExecutor)
53 return false;
54
55 return SCR_TaskSystem.GetInstance().CanTaskBeAssignedTo(task, groupExecutor);
56 }
57}
58
59class SCR_TaskListUIComponent : SCR_ScriptedWidgetComponent
60{
61 [Attribute("{B71975032150BAFB}UI/layouts/Task/TaskListEntry.layout", params: "layout")]
62 protected ResourceName m_sTaskListEntryLayout;
64 [Attribute("{A5326D834EB28E28}UI/layouts/Task/TaskListTabEntry.layout", params: "layout")]
65 protected ResourceName m_sTaskTabEntryLayout;
66
67 [Attribute("")]
68 protected ref array<ref SCR_TaskTabStates> m_aTaskTabStates;
69
71
75
78 protected SCR_MapCursorModule m_MapCursorModule;
79
83 protected ref array<string> m_aAllowedTaskTypenames = {};
84
85 //------------------------------------------------------------------------------------------------
86 override void HandlerAttached(Widget w)
87 {
88 super.HandlerAttached(w);
89
90 m_Widgets.Init(m_wRoot);
91
92 m_TaskSystem = SCR_TaskSystem.GetInstance();
93 if (!m_TaskSystem)
94 return;
95
97
98 m_Widgets.m_wTaskListEntryDescription.SetVisible(false);
100
102 m_TaskListDescriptionComponent.GetOnButtonShowOnMap().Insert(ShowTaskOnMap);
103
104 if (m_Widgets.m_HideTasksButtonComponent)
105 m_Widgets.m_HideTasksButtonComponent.m_OnActivated.Insert(OnHideButton);
106
108 if (m_TaskManager)
109 {
110 m_TaskManager.RegisterTaskList(this);
111 m_TaskManager.GetOnTaskSelected().Insert(OnTaskSelected);
113 }
114
115 m_TaskSystem.GetOnTaskAdded().Insert(OnTaskAdded);
116 m_TaskSystem.GetOnTaskRemoved().Insert(OnTaskRemoved);
117 }
118
119 //------------------------------------------------------------------------------------------------
120 override void HandlerDeattached(Widget w)
121 {
122 super.HandlerDeattached(w);
123
125 m_TaskListDescriptionComponent.GetOnButtonShowOnMap().Remove(ShowTaskOnMap);
126
127 if (m_Widgets.m_HideTasksButtonComponent)
128 m_Widgets.m_HideTasksButtonComponent.m_OnActivated.Remove(OnHideButton);
129
130 if (m_TaskManager)
131 {
132 m_TaskManager.RegisterTaskList(null);
133 m_TaskManager.GetOnTaskSelected().Remove(OnTaskSelected);
134 }
135
136 if (m_TaskSystem)
137 {
138 m_TaskSystem.GetOnTaskAdded().Remove(OnTaskAdded);
139 m_TaskSystem.GetOnTaskRemoved().Remove(OnTaskRemoved);
140 }
141 }
142
143 //------------------------------------------------------------------------------------------------
145 {
146 Widget widget;
147 if (!task && m_eSelectedTab == SCR_ETaskTabType.AVAILABLE && !m_mTasksMap.IsEmpty() && m_mTasksMap.GetElement(0))
148 widget = m_mTasksMap.GetElement(0).GetEntryButton();
149
150 if (!widget)
151 {
153 if (comp)
154 widget = comp.GetEntryButton();
155 }
156
157 if (widget)
158 {
159 GetGame().GetWorkspace().SetFocusedWidget(widget);
160 }
161 else
162 {
163 Widget w = m_Widgets.m_wTabsWrapper.GetChildren();
164 if (w)
165 GetGame().GetWorkspace().SetFocusedWidget(w);
166 }
167 }
168
169 //------------------------------------------------------------------------------------------------
170 protected void OnTabClicked(notnull SCR_ScriptedWidgetComponent comp)
171 {
173 if (!tabComp)
174 return;
175
176 SCR_ETaskTabType type = tabComp.GetTabType();
177 if (type == m_eSelectedTab)
178 return;
179
181
183
184 Widget widget = tabComp.GetRootWidget();
185
186 array<ref Widget> tabsArray = {};
187 SCR_WidgetHelper.GetAllChildren(m_Widgets.m_wTabsWrapper, tabsArray);
189 foreach (Widget w : tabsArray)
190 {
192 if (!component)
193 return;
194
195 if (w == widget)
196 component.ChangeTabColor(UIColors.CONTRAST_COLOR);
197 else
198 component.ChangeTabColor(GUIColors.DEFAULT_GLOW);
199 }
200
201 m_Widgets.m_wTasksListScroll.SetSliderPos(0, 0);
202 }
203
204 //------------------------------------------------------------------------------------------------
205 override bool OnMouseEnter(Widget w, int x, int y)
206 {
207 super.OnMouseEnter(w, x, y);
208
209 if (!m_MapEntity)
211
212 if (!m_MapEntity)
213 return false;
214
216 m_MapCursorModule = SCR_MapCursorModule.Cast(m_MapEntity.GetMapModule(SCR_MapCursorModule));
217
219 m_MapCursorModule.SetJournalVisibility(true);
220
221 return false;
222 }
223
224 //------------------------------------------------------------------------------------------------
225 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
226 {
227 super.OnMouseLeave(w, enterW, x, y);
228 if (enterW && enterW.GetTypeName() == "ButtonWidget")
229 return false;
230
231 if (!m_MapEntity)
233
234 if (!m_MapEntity)
235 return false;
236
238 m_MapCursorModule = SCR_MapCursorModule.Cast(m_MapEntity.GetMapModule(SCR_MapCursorModule));
239
241 m_MapCursorModule.SetJournalVisibility(false);
242
243 return false;
244 }
245
246 //------------------------------------------------------------------------------------------------
254
255 //------------------------------------------------------------------------------------------------
258 {
259 SCR_ExtendedTask extendedTask;
260 foreach (SCR_Task oldTask, SCR_TaskListEntryUIComponent oldComponent : m_mTasksMap)
261 {
262 if (!oldComponent)
263 continue;
264
265 extendedTask = SCR_ExtendedTask.Cast(oldTask);
266 if (extendedTask)
267 {
268 extendedTask.GetOnChildTaskAdded().Remove(OnChildTaskChanged);
269 extendedTask.GetOnChildTaskRemoved().Remove(OnChildTaskChanged);
270 }
271 oldComponent.GetOnTaskVisualChanged().Remove(OnTaskVisualChanged);
272 oldComponent.GetRootWidget().RemoveFromHierarchy();
273 }
274
275 m_mTasksMap.Clear();
276
277 //## Select states to check based on opened tab
278 Widget parent;
279 if (m_eSelectedTab == SCR_ETaskTabType.FINISHED)
280 parent = m_Widgets.m_wTasksWrapper;
281
282 SCR_ETaskState stateToCheck = GetStateToCheck();
283 array<SCR_Task> allTasks = {};
284 m_TaskSystem.GetTasksByState(allTasks, stateToCheck);
285 if (allTasks.IsEmpty())
286 {
288 return;
289 }
290
291 int playerID = GetGame().GetPlayerController().GetPlayerId();
292 SCR_TaskExecutor player = SCR_TaskExecutor.FromPlayerID(playerID);
293 foreach (SCR_Task task : allTasks)
294 {
295 if (!m_TaskSystem.IsTaskVisibleInTaskList(task))
296 continue;
297
298 if (m_TaskSystem.IsTaskVisibleFor(task, player))
299 CreateTaskEntry(task, parent, stateToCheck);
300
301 extendedTask = SCR_ExtendedTask.Cast(task);
302 if (extendedTask)
303 {
304 extendedTask.GetOnChildTaskAdded().Insert(OnChildTaskChanged);
305 extendedTask.GetOnChildTaskRemoved().Insert(OnChildTaskChanged);
306 }
307 }
308
309 foreach (SCR_Task task : allTasks)
310 {
311 if (!m_TaskSystem.IsTaskVisibleInTaskList(task))
312 continue;
313
314 if (m_TaskSystem.IsTaskVisibleFor(task, player))
316 }
317
319 {
320 SCR_Task descriptionTask = m_TaskListDescriptionComponent.GetCurrentTask();
321 if (descriptionTask && (!m_TaskSystem.IsTaskVisibleFor(descriptionTask, SCR_TaskExecutor.FromPlayerID(playerID)) || (descriptionTask.GetTaskState() & (SCR_ETaskState.COMPLETED | SCR_ETaskState.FAILED | SCR_ETaskState.CANCELLED))))
322 CollapseTask();
323 }
324 }
325
326 //------------------------------------------------------------------------------------------------
328 {
329 foreach (SCR_TaskTabStates tab : m_aTaskTabStates)
330 {
331 if (tab.GetTabType() != m_eSelectedTab)
332 continue;
333
334 return tab.GetTaskStates();
335 }
336
337 return -1;
338 }
339
340 //------------------------------------------------------------------------------------------------
342 {
343 foreach (SCR_TaskTabStates tab : m_aTaskTabStates)
344 {
345 if (tab.GetTabType() == m_eSelectedTab)
346 return tab.IsTaskVisible(task);
347 }
348
349 return true;
350 }
351
352 //------------------------------------------------------------------------------------------------
353 protected void InitializeTaskTabs()
354 {
355 m_eSelectedTab = m_TaskManager.GetDefaultTaskTab();
356
357 Widget w;
359 foreach (SCR_ETaskTabType tab : m_TaskManager.GetTaskTabs())
360 {
361 w = GetGame().GetWorkspace().CreateWidgets(m_sTaskTabEntryLayout, m_Widgets.m_wTabsWrapper);
362 if (!w)
363 return;
364
366 if (!comp)
367 return;
368
369 comp.Initialize(tab);
370
371 if (m_eSelectedTab == tab)
372 comp.ChangeTabColor(UIColors.CONTRAST_COLOR);
373
374 comp.m_OnClick.Insert(OnTabClicked);
375 }
376 }
377
378 //------------------------------------------------------------------------------------------------
382 protected void CreateTaskEntry(notnull SCR_Task task, Widget parent = null, SCR_ETaskTabType tabType = SCR_ETaskTabType.AVAILABLE)
383 {
384 // if m_aAllowedTaskTypenames array is set, it will be showed only tasks from the array
385 if (!m_aAllowedTaskTypenames.IsEmpty() && !m_aAllowedTaskTypenames.Contains(task.Type().ToString()))
386 return;
387
388 if (!parent)
389 parent = m_Widgets.m_wTasksWrapper;
390
391 Widget taskWidget = GetGame().GetWorkspace().CreateWidgets(m_sTaskListEntryLayout, parent);
392 if (!taskWidget)
393 return;
394
396 if (!taskComp)
397 return;
398
400 m_mTasksMap.Insert(task, taskComp);
401
402 array<SCR_Task> childTasks = {};
403 m_TaskSystem.GetChildTasksFor(task, childTasks);
404
405 bool isChildVisible;
406 if (childTasks)
407 {
408 foreach (SCR_Task child : childTasks)
409 {
410 if (m_TaskSystem.IsTaskVisibleInTaskList(child))
411 isChildVisible = true;
412 }
413 }
414
415 bool hasChildTasks = childTasks && isChildVisible && !childTasks.IsEmpty() && tabType & SCR_ETaskTabType.FINISHED;
416 taskComp.InitTask(task, hasChildTasks);
417 if (!hasChildTasks)
418 return;
419
420 taskComp.SetChildCount(childTasks.Count());
421 }
422
423 //------------------------------------------------------------------------------------------------
426 protected void ReparentTask(SCR_Task task)
427 {
428 SCR_Task parentTask;
429 Widget parentWrapper;
430 m_TaskSystem.GetParentTasksFor(task, parentTask);
431 if (parentTask)
432 {
433 SCR_TaskListEntryUIComponent parentComp = m_mTasksMap.Get(parentTask);
434 if (!parentComp)
435 return;
436
437 parentWrapper = parentComp.GetChildWrapper();
438 if (!parentWrapper)
439 return;
440 }
441
442 if (!parentWrapper)
443 parentWrapper = m_Widgets.m_wTasksWrapper;
444
445 if (!parentWrapper)
446 return;
447
449 if (!taskComp)
450 return;
451
452 Widget childWidget = taskComp.GetRootWidget();
453 if (!childWidget)
454 return;
455
456 parentWrapper.AddChild(childWidget);
457 }
458
459 //------------------------------------------------------------------------------------------------
462 protected void UnfoldParent(notnull SCR_Task task)
463 {
465 if (parentUIComp)
466 parentUIComp.SetChildWrapperFolded(null, true);
467
468 SCR_Task parentTask;
469 m_TaskSystem.GetParentTasksFor(task, parentTask);
470 if (parentTask)
471 UnfoldParent(parentTask);
472 }
473
474 //------------------------------------------------------------------------------------------------
477 protected void OnTaskSelected(notnull SCR_Task task)
478 {
479 // Collapse already selected task
480 CollapseTask();
481
483 if (!taskUIComp)
484 {
486 return;
487 }
488
490 {
492 return;
493 }
494
496 ExpandTask(task, taskUIComp);
497 }
498
499 //------------------------------------------------------------------------------------------------
502 protected void OnTaskAdded(SCR_Task task)
503 {
504 SCR_ExtendedTask extendedTask = SCR_ExtendedTask.Cast(task);
505 if (extendedTask)
506 {
507 SCR_Task parentTask = extendedTask.GetParentTask();
508 if (!parentTask)
509 {
511 return;
512 }
513
514 SCR_TaskListEntryUIComponent component = m_mTasksMap.Get(parentTask);
515 Widget widget = component.GetRootWidget();
516
517 CreateTaskEntry(task, widget);
518 }
519 else
520 {
522 }
523 }
524
525 //------------------------------------------------------------------------------------------------
528 protected void OnTaskRemoved(notnull SCR_Task task)
529 {
530 SCR_ExtendedTask extendedTask = SCR_ExtendedTask.Cast(task);
531 if (extendedTask)
532 {
533 extendedTask.GetOnChildTaskAdded().Insert(OnChildTaskChanged);
534 extendedTask.GetOnChildTaskRemoved().Insert(OnChildTaskChanged);
535 }
536
538 if (!m_mTasksMap.Find(task, taskComp))
539 return;
540
541 if (taskComp)
542 {
544 taskComp.GetRootWidget().RemoveFromHierarchy();
545
548 }
549
550 m_mTasksMap.Remove(task);
551 }
552
553 //------------------------------------------------------------------------------------------------
555 protected void OnHideButton()
556 {
557 if (!IsVisible())
558 return;
559
561 m_OnButtonTaskListHide.Invoke();
562
564 }
565
566 //------------------------------------------------------------------------------------------------
570 {
571 m_TaskListDescriptionComponent.InitDescription(task);
572 }
573
574 //------------------------------------------------------------------------------------------------
578 {
580 }
581
582 //------------------------------------------------------------------------------------------------
586 protected void ExpandTask(notnull SCR_Task task, notnull SCR_TaskListEntryUIComponent taskUIComp)
587 {
588 // Show Description of task
590 return;
591
593
594 m_TaskListDescriptionComponent.InitDescription(task);
595
596 m_Widgets.m_wTaskListEntryDescription.SetVisible(true);
597 taskUIComp.SetEntrySelected(true);
598 }
599
600 //------------------------------------------------------------------------------------------------
604 {
605 m_Widgets.m_wTaskListEntryDescription.SetVisible(false);
606
608 return;
609
611 if (component)
612 component.SetEntrySelected(false);
613 }
614
615 //------------------------------------------------------------------------------------------------
617 protected void ShowTaskOnMap()
618 {
619 m_TaskManager.ShowTaskOnMap();
620 }
621
622 //------------------------------------------------------------------------------------------------
626 {
627 m_Widgets.m_wSizeLayout.SetHeightOverride(size);
628 }
629
630 //------------------------------------------------------------------------------------------------
633 void SetTaskListVisibility(bool show = false)
634 {
635 m_wRoot.SetVisible(show);
636 }
637
638 //------------------------------------------------------------------------------------------------
641 {
642 return IsVisible();
643 }
644
645 //------------------------------------------------------------------------------------------------
647 void SetTaskDescriptionVisiblity(bool visibility)
648 {
649 if (visibility)
650 {
651 SCR_Task task = m_TaskManager.GetSelectedTask();
652 if (task)
653 {
655 if (taskComp)
656 ExpandTask(task, taskComp);
657 }
658 }
659 else
660 {
661 CollapseTask();
662 }
663 }
664
665 //------------------------------------------------------------------------------------------------
668 {
669 if (m_Widgets.m_wTaskListEntryDescription)
670 return m_Widgets.m_wTaskListEntryDescription.IsVisible();
671
672 return false;
673 }
674
675 //------------------------------------------------------------------------------------------------
684
685 //------------------------------------------------------------------------------------------------
693
694 //------------------------------------------------------------------------------------------------
697 void AddAllowedTaskTypenames(notnull array<string> allowedTaskTypenames)
698 {
699 foreach (string taskTypename : allowedTaskTypenames)
700 {
701 if (!m_aAllowedTaskTypenames.Contains(taskTypename))
702 m_aAllowedTaskTypenames.Insert(taskTypename);
703 }
704 }
705}
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void OnTaskSelected(SCR_Task task)
SCR_CampaignSeizingComponent SCR_SeizingComponent EnumLinear()] enum SCR_EBaseCaptureState
EDamageType type
void OnTaskAdded(notnull SCR_Task task)
void OnTaskRemoved(notnull SCR_Task task)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
SCR_MapCursorModule m_MapCursorModule
Widget m_wRoot
SCR_MapEntity m_MapEntity
ref SCR_HeaderNavigationWidgets m_Widgets
string GetTaskDescription()
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
override void HandlerDeattached(Widget w)
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
SCR_ETaskState
Definition SCR_Task.c:3
void OnChildTaskChanged(SCR_Task task)
enum SCR_ETaskTabType SCR_BaseContainerCustomTitleEnum(SCR_ETaskTabType, "m_eTabType")
override bool IsTaskVisible(notnull SCR_Task task)
void SetTaskListVisibility(bool show=false)
ref map< SCR_Task, SCR_TaskListEntryUIComponent > m_mTasksMap
bool GetTaskListVisibility()
SCR_Task m_CurrentlySelectedTask
void CreateTaskEntry(notnull SCR_Task task, Widget parent=null, SCR_ETaskTabType tabType=SCR_ETaskTabType.AVAILABLE)
SCR_ETaskState GetStateToCheck()
void OnHideButton()
Triggered on hide tasks button clicked, hides task list.
ref array< ref SCR_TaskTabStates > m_aTaskTabStates
void OnTabClicked(notnull SCR_ScriptedWidgetComponent comp)
ScriptInvokerVoid GetOnButtonTaskListHide()
void FocusOnEntry(SCR_Task task=null)
void RefreshTaskList()
Get a list of all available to display tasks. If entry for task is already created,...
bool GetTaskDescriptionVisiblity()
SCR_TaskListEntryDescriptionUIComponent m_TaskListDescriptionComponent
void OnTaskVisualChanged(SCR_Task task)
bool IsTaskVisibleInListByTab(notnull SCR_Task task)
void UnfoldParent(notnull SCR_Task task)
void InitializeTaskTabs()
void AddAllowedTaskTypenames(notnull array< string > allowedTaskTypenames)
SCR_TaskManagerUIComponent m_TaskManager
void CollapseTask()
void ReparentTask(SCR_Task task)
ref ScriptInvokerVoid m_OnButtonTaskListHide
void SetTaskListHeight(float size)
void ExpandTask(notnull SCR_Task task, notnull SCR_TaskListEntryUIComponent taskUIComp)
ref array< string > m_aAllowedTaskTypenames
void SetTaskDescriptionVisiblity(bool visibility)
SCR_ETaskTabType m_eSelectedTab
void RequestRefreshFactionChange(SCR_Task task, FactionKey factionKey)
void ShowTaskOnMap()
Opens map and moves camera to task location.
SCR_TaskSystem m_TaskSystem
SCR_ChildTaskInvoker GetOnChildTaskRemoved()
SCR_ChildTaskInvoker GetOnChildTaskAdded()
static SCR_MapEntity GetMapInstance()
Get map entity instance.
void SetChildCount(int count)
Widget GetChildWrapper()
Widget GetEntryButton()
void InitTask(notnull SCR_Task task, bool hasChild=false)
void SetEntrySelected(bool selected)
void SetChildWrapperFolded(SCR_ModularButtonComponent comp=null, bool toggled=-1)
Toggles child tasks fold.
SCR_TaskVisualsChangedInvoker GetOnTaskVisualChanged()
void ChangeTabColor(Color color)
SCR_ETaskTabType GetTabType()
void Initialize(SCR_ETaskTabType tab)
static SCR_TaskManagerUIComponent GetInstance()
Definition Types.c:486
@ FINISHED
Job was successfully finished.
Definition ENodeResult.c:19
SCR_FieldOfViewSettings Attribute
@ ALL
Everything except general switch.
Definition EntityEvent.c:37