Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapTaskListUI.c
Go to the documentation of this file.
2 {
3  const string TASK_LIST_FRAME = "MapTaskList";
4  const string ICON_NAME = "faction";
5 
6  protected Widget m_wUI;
7  protected OverlayWidget m_wTaskListFrame;
8  protected SCR_UITaskManagerComponent m_UITaskManager;
9  protected SCR_MapToolMenuUI m_ToolMenu;
10  protected SCR_MapToolEntry m_ToolMenuEntry;
11  protected SCR_BaseTask m_LastSelectedTask;
12 
13  protected bool m_bTaskListInvoked;
14  protected bool m_bOpened;
15  protected bool m_bOnMapClose;
16  protected bool m_bMapContextAllowed = true;
17 
18  [Attribute("JournalFrame", desc: "Journal frame widget name")]
19  protected string m_sJournalFrameName;
20 
21  [Attribute("MapTaskList", desc: "Map task list root widget name")]
22  protected string m_sMapTaskListRootName;
23 
24  [Attribute("MapTaskListFrame", desc: "Map task list root frame widget name")]
25  protected string m_sMapTaskListRootFrameName;
26 
27  [Attribute("exclamationCircle", desc: "Journal Toolmenu imageset quad name")]
28  protected string m_sJournalToolMenuIconName;
29 
30  //------------------------------------------------------------------------------------------------
31  override protected void OnMapOpen(MapConfiguration config)
32  {
33  m_bOnMapClose = false;
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  override protected void OnMapClose(MapConfiguration config)
38  {
39  if (m_UITaskManager)
40  {
41  m_bOnMapClose = true;
42  m_UITaskManager.Action_TasksClose();
43  m_UITaskManager.ClearWidget();
44  m_UITaskManager.CreateTaskList();
45  }
46 
47  m_ToolMenuEntry.SetActive(false);
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  override void Init()
52  {
53  m_UITaskManager = SCR_UITaskManagerComponent.GetInstance();
54  if (!m_UITaskManager)
55  {
56  SetActive(false); // deactivate component
57  return;
58  }
59 
60  m_ToolMenu = SCR_MapToolMenuUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolMenuUI));
61  if (m_ToolMenu)
62  {
63  m_ToolMenuEntry = m_ToolMenu.RegisterToolMenuEntry(SCR_MapToolMenuUI.s_sToolMenuIcons, ICON_NAME, 2);
64  m_ToolMenuEntry.m_OnClick.Insert(OnMapTaskListClicked);
65  m_ToolMenuEntry.SetButtonSoundsDisabled(true);
66  }
67 
68  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
69 
70  //If there is a OverlayWidget like on the DeployMenu we use that instead of the default one
71  m_wTaskListFrame = OverlayWidget.Cast(m_RootWidget.FindAnyWidget(TASK_LIST_FRAME));
72  if (!m_wTaskListFrame)
73  return;
74 
75  m_wUI = m_UITaskManager.CreateTaskList(m_wTaskListFrame);
76  }
77 
78  //------------------------------------------------------------------------------------------------
80  void SetMapContextAllowed(bool val)
81  {
83  }
84 
85  //------------------------------------------------------------------------------------------------
87  void ToggleTaskList(SCR_BaseTask taskToFocus = null)
88  {
89  if (!m_bOpened)
90  {
91  m_UITaskManager.ClearWidget();
92  if (!m_wTaskListFrame)
93  m_wTaskListFrame = OverlayWidget.Cast(m_RootWidget.FindAnyWidget(TASK_LIST_FRAME));
94 
95  m_wUI = m_UITaskManager.CreateTaskList(m_wTaskListFrame);
96  if (m_wUI)
97  {
98  m_bOpened = true;
99  m_bTaskListInvoked = true;
100  m_UITaskManager.Action_ShowTasks(m_wUI, taskToFocus);
101  m_ToolMenuEntry.SetActive(true);
102  m_LastSelectedTask = taskToFocus;
103  }
104  }
105  else if (taskToFocus && taskToFocus != m_LastSelectedTask)
106  {
107  m_UITaskManager.Action_ShowTasks(m_wUI, taskToFocus);
108  m_LastSelectedTask = taskToFocus;
109  }
110  else
111  {
112  m_bOpened = false;
113  m_bTaskListInvoked = true;
114  m_UITaskManager.Action_TasksClose();
115  m_ToolMenuEntry.SetActive(false);
116  }
117 
118  m_bTaskListInvoked = false;
119  }
120 
121  //------------------------------------------------------------------------------------------------
123  void RefreshTaskList()
124  {
125  if (!m_bOpened)
126  return;
127 
128  m_UITaskManager.ClearWidget();
129  if (!m_wTaskListFrame)
130  m_wTaskListFrame = OverlayWidget.Cast(m_RootWidget.FindAnyWidget(TASK_LIST_FRAME));
131 
132  m_wUI = m_UITaskManager.CreateTaskList(m_wTaskListFrame);
133  if (!m_wUI)
134  return;
135 
136  m_bOpened = true;
137  m_bTaskListInvoked = true;
138  m_UITaskManager.Action_ShowTasks(m_wUI);
139  m_ToolMenuEntry.SetActive(true);
140  }
141 
142  //------------------------------------------------------------------------------------------------
143  protected void OnMapTaskListClicked(SCR_ButtonBaseComponent comp)
144  {
145  HandleTaskList();
146  }
147 
148  //------------------------------------------------------------------------------------------------
151  void HandleTaskList(bool isVisible = true, SCR_BaseTask taskToFocus = null)
152  {
153  if (!m_RootWidget)
154  return;
155 
156  Widget taskListRoot = m_RootWidget.FindAnyWidget(m_sMapTaskListRootName);
157  if (!taskListRoot)
158  return;
159 
160  taskListRoot.SetVisible(isVisible);
161  Widget taskListRootFrame = m_RootWidget.FindAnyWidget(m_sMapTaskListRootFrameName);
162  if (!taskListRootFrame)
163  {
164  ToggleTaskList(taskToFocus);
165  return;
166  }
167 
168  taskListRootFrame.SetVisible(isVisible);
169  foreach (SCR_MapToolEntry toolEntry : m_ToolMenu.GetMenuEntries())
170  {
171  if (toolEntry.GetImageSet() != m_sJournalToolMenuIconName)
172  continue;
173 
174  Widget mapJournalFrame = m_RootWidget.FindAnyWidget(m_sJournalFrameName);
175  if (mapJournalFrame && mapJournalFrame.IsVisible())
176  {
177  mapJournalFrame.SetVisible(false);
178  toolEntry.SetActive(false);
179  }
180  }
181 
182  ToggleTaskList(taskToFocus);
183  }
184 
185  //------------------------------------------------------------------------------------------------
186  protected void OnInputDeviceIsGamepad(bool isGamepad)
187  {
188  if (isGamepad && m_bOpened)
189  {
190  m_bMapContextAllowed = false;
191  return;
192  }
193 
194  m_bMapContextAllowed = true;
195  }
196 
197  //------------------------------------------------------------------------------------------------
198  override void HandlerDeattached(Widget w)
199  {
200  if (SCR_Global.IsEditMode())
201  return;
202 
203  GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
204  }
205 }
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
m_RootWidget
protected Widget m_RootWidget
Definition: SCR_BinocularsComponent.c:10
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_ToolMenuEntry
protected SCR_MapToolEntry m_ToolMenuEntry
Definition: SCR_MapDrawingUI.c:182
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_MapToolEntry
Map tool menu entry data class.
Definition: SCR_MapToolMenuUI.c:2
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
SCR_UITaskManagerComponent
void SCR_UITaskManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_UITaskManagerComponent.c:1096
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
SCR_MapTaskListUI
Definition: SCR_MapTaskListUI.c:1
m_LastSelectedTask
protected SCR_BaseTask m_LastSelectedTask
Definition: SCR_UITaskManagerComponent.c:36
SCR_Global
Definition: Functions.c:6
SetActive
void SetActive(bool active)
Definition: SCR_LoadoutSaveBlackListHolder.c:90
m_bMapContextAllowed
protected bool m_bMapContextAllowed
Definition: SCR_DeployMenuBase.c:139
SCR_MapUIBaseComponent
Definition: SCR_MapUIBaseComponent.c:3
m_wUI
protected Widget m_wUI
Definition: SCR_UITaskManagerComponent.c:18
SCR_MapToolMenuUI
void SCR_MapToolMenuUI()
Definition: SCR_MapToolMenuUI.c:389