Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TaskSelectButton.c
Go to the documentation of this file.
1 class SCR_TaskSelectButton : ScriptedWidgetComponent
2 {
3  protected SCR_MapUITask m_MapUiTask;
4  protected ref ScriptInvoker m_OnMapIconClick;
5 
6  static const int VISIBLE = 1;
7  static const int NOT_VISIBLE = 0;
8 
9  //------------------------------------------------------------------------------
10  ScriptInvoker GetOnMapIconClick()
11  {
12  if (!m_OnMapIconClick)
13  m_OnMapIconClick = new ScriptInvoker();
14 
15  return m_OnMapIconClick;
16  }
17 
18  //------------------------------------------------------------------------------
19  override bool OnClick(Widget w, int x, int y, int button)
20  {
21  if (m_OnMapIconClick)
22  m_OnMapIconClick.Invoke();
23 
24  SCR_MapEntity mapEntity = SCR_MapEntity.GetMapInstance();
25  if (!mapEntity)
26  return false;
27 
28  SCR_MapTaskListUI taskListUI = SCR_MapTaskListUI.Cast(mapEntity.GetMapUIComponent(SCR_MapTaskListUI));
29  if (!taskListUI)
30  return false;
31 
32  taskListUI.HandleTaskList(taskToFocus: m_MapUiTask.GetTask());
33 
34  return false;
35  }
36 
37  //------------------------------------------------------------------------------
38  override bool OnMouseEnter(Widget w, int x, int y)
39  {
40  m_MapUiTask.UpdateFocusedTask();
41 
42  ButtonWidget assignButton = ButtonWidget.Cast(m_MapUiTask.GetMapWidget().FindAnyWidget("TaskTitleButton"));
43  Widget assignees = Widget.Cast(m_MapUiTask.GetMapWidget().FindAnyWidget("Assignee"));
44  Widget iconHover = Widget.Cast(m_MapUiTask.GetMapWidget().FindAnyWidget("TaskIconHover"));
45 
46  if (!assignButton || !assignees || !iconHover)
47  return false;
48 
49  assignButton.SetVisible(true);
50 
51  assignees.SetEnabled(HasAssigneeBool());
52  assignees.SetOpacity(HasAssigneeInt());
53 
54  iconHover.SetEnabled(true);
55  iconHover.SetOpacity(VISIBLE);
56 
57  GetGame().GetInputManager().AddActionListener("MenuSelect", EActionTrigger.DOWN, ButtonPressed);
58 
59  return false;
60  }
61 
62  //------------------------------------------------------------------------------
63  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
64  {
65  GetGame().GetInputManager().RemoveActionListener("MenuSelect", EActionTrigger.DOWN, ButtonPressed);
66  return false;
67  }
68 
69  //------------------------------------------------------------------------------
70  void ButtonPressed()
71  {
72  if (m_OnMapIconClick)
73  m_OnMapIconClick.Invoke();
74 
75  SCR_MapEntity mapEntity = SCR_MapEntity.GetMapInstance();
76  if (!mapEntity)
77  return;
78 
79  SCR_MapTaskListUI taskListUI = SCR_MapTaskListUI.Cast(mapEntity.GetMapUIComponent(SCR_MapTaskListUI));
80  if (!taskListUI)
81  return;
82 
83  taskListUI.HandleTaskList(taskToFocus: m_MapUiTask.GetTask());
84  }
85  //------------------------------------------------------------------------------
86  bool HasAssigneeBool()
87  {
88  SCR_BaseTask task = m_MapUiTask.GetTask();
89  if (!task)
90  return false;
91 
92  if (task.GetAssigneeCount() == 0)
93  return false;
94 
95  return true;
96  }
97 
98  //------------------------------------------------------------------------------
99  int HasAssigneeInt()
100  {
101  SCR_BaseTask task = m_MapUiTask.GetTask();
102  if (!task)
103  return NOT_VISIBLE;
104 
105  if (task.GetAssigneeCount() == 0)
106  return NOT_VISIBLE;
107 
108  return VISIBLE;
109  }
110 
111  //------------------------------------------------------------------------------
112  void SetRootWidgetHandler(SCR_MapUITask mapUiTask)
113  {
114  m_MapUiTask = mapUiTask;
115  }
116 };
VISIBLE
@ VISIBLE
Entity is marked as visible (SCR_EditableEntityComponent.SetVisible())
Definition: EEditableEntityState.c:40
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
SCR_MapUITask
Definition: SCR_MapUITask.c:2
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
SCR_MapTaskListUI
Definition: SCR_MapTaskListUI.c:1
SCR_TaskSelectButton
Definition: SCR_TaskSelectButton.c:1